title: Accessing C++ typedef in Python using SWIG
body: <p>I have a C++ API I'm trying to wrap in Python. I want to call a wrapped C++ function myfunc taking as an argument the following C++ typedef</p>
  
  <pre class="lang-cpp prettyprint-override"><code>/* my_header.h */
  
  namespace my_namespace {
  typedef std::vector&lt;Foo&gt; Bar
  }
  </code></pre>
  
  <p>where Foo is a C++ class. I managed to wrap the function and the underlying class Foo, but I don't know how to create the vector of Foo. I included the .h file in my SWIG .i file as follows</p>
  
  <pre class="lang-cpp prettyprint-override"><code>/* my_interface.i */
  
  %{
  #include "my_header.h"
  typedef my_namespace::Bar Bar;
  %}
  
  %include "my_header.h"
  </code></pre>
  
  <p>I also tried wrapping the std::vector template in SWIG, as follows</p>
  
  <pre class="lang-cpp prettyprint-override"><code>%include std_vector.i
  namespace std {
      %template(vector_foo) vector&lt;Foo&gt;;
  }
  </code></pre>
  
  <p>This works, and I can import vector_foo in Python. However, when I send a vector_foo as an argument to the function mentioned above, I get a TypeError. Neither am I able to populate vector_foo with Foo.</p>
  
  <p>In Python I do the following</p>
  
  <pre class="lang-python prettyprint-override"><code>&gt;&gt;&gt; a = mymodule.vector_foo()
  &gt;&gt;&gt; a
  &lt;Swig Object of type 'std::vector &lt;Foo, std::allocator&lt; Foo &gt; &gt; *'
  &gt;&gt;&gt; mymodule.myfunc(a, 'string')
  TypeError: in method 'myfunc', argument 1 of type 'my_namespace::Bar &amp;'
  </code></pre>
  
  <p>Either if I can make my own implementation of vector of Foo work, or somehow access the C++ typedef directly. I'm calling SWIG and compiling using Python Distutils. </p>
  
  <p>Thanks for any help!</p>