title: C++/SWIG typemap passed by reference
body: <p>I have the following C++ code that I want to be usable from Python. The wrapping is made with SWIG.</p>
  
  <p>Header file:</p>
  
  <pre><code>#ifndef FSINDEXTRANSFORM_H
  #define FSINDEXTRANSFORM_H
  
  class FSIndexTransform
  {
  public:
  typedef int IndexVec3;
  
  void Transform(const IndexVec3 indices, const IndexVec3 begin1, const IndexVec3 begin2, IndexVec3&amp; result) const;
  };
  
  #endif
  </code></pre>
  
  <p>Source file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "FSIndexTransform.h"
  
  void FSIndexTransform::Transform(const IndexVec3 indices,
                                  const IndexVec3 begin1,
                                  const IndexVec3 begin2,
                                  IndexVec3&amp; result) const
  {
  std::cout &lt;&lt; "OK" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>SWIG header:</p>
  
  <pre><code>%module FSIndexTransform
  
  %{
  #include "FSIndexTransform.h"
  %}
  
  %include "FSIndexTransform.h"
  </code></pre>
  
  <p>I am trying to use the generated Python module as follows:</p>
  
  <pre><code>from FSIndexTransform import FSIndexTransform
  transform = FSIndexTransform()
  transform.Transform(1, 2, 3, 4)
  </code></pre>
  
  <p>According to <a href="http://www.swig.org/Doc2.0/SWIGDocumentation.html#Python_nn22" rel="nofollow noreferrer">SWIG documentation</a>, <em>const IndexVec3</em> and <em>IndexVec3&amp;</em> arguments should be processed the same way. But this is not the behavior I observe:</p>
  
  <pre><code>Traceback (most recent call last):
  File "test.py", line 13, in &lt;module&gt;
      transform.Transform(1, 2, 3, 4)
  File "/projects/fsdm/dev/st15435/FlowSim/FSDM/trunk/test_fsindextransform/bin/FSIndexTransform.py", line 101, in Transform
      return _FSIndexTransform.FSIndexTransform_Transform(self, indices, begin1, begin2, result)
  TypeError: in method 'FSIndexTransform_Transform', argument 5 of type 'FSIndexTransform::IndexVec3 &amp;'
  </code></pre>
  
  <p>When looking to the FSIndexTransform_wrap.cpp, one can see that the translation is not done the same way for all parameters:</p>
  
  <pre><code>FSIndexTransform::IndexVec3 arg2 ; 
  FSIndexTransform::IndexVec3 arg3 ;
  FSIndexTransform::IndexVec3 arg4 ; 
  FSIndexTransform::IndexVec3 *arg5 = 0
  </code></pre>
  
  <p>I didn't manage to use (or to understand) similar discussions I have found.</p>