title: SWIG C++ to Python: returning an std::list as an argument to Python
body: <p>I'm trying to call a method in C++ from Python that returns an std::list as a parameter.</p>
  
  <p>Here is the C++ prototype:</p>
  
  <pre><code>void FindAllServices(int id, std::list&lt;Service*&gt; &amp;services)
  </code></pre>
  
  <p>Here is my typemap for std::list:</p>
  
  <pre><code>%typemap(in) (std::list&lt;Service*&gt; &amp;) (std::list&lt;Service*&gt; temp) {
    $1 = &amp;temp;
  }
  
  %typemap(argout) (std::list&lt;Service*&gt;&amp;) {
      Py_XDECREF($result);   /* Blow away any previous result */
      $result = PyList_New((*$1).size());
      qList&lt;Service*&gt;::iterator it = (*$1).begin();
      int i = 0;
      while(it != (*$1).end()) {
          PyList_SetItem($result,i,SWIG_NewPointerObj((void*)(*it), SWIGTYPE_p_Service, 0));
          it++; i++;
      }
  }
  </code></pre>
  
  <p>When I call the function from Python, I can break in the C++ code and see that everything is fine (i.e. some Service pointers got copied in the list). However, the list I get in Python is empty.</p>
  
  <p>Do you have any idea what I might be doing wrong?</p>
  
  <p>Thanks!</p>