title: Boost.Python.ArgumentError: python str not converted to std::string
body: <p>I get an error I can't make sense of trying to wrap a rather simple c++ class via Boost.Python.
  First, the class:</p>
  
  <pre><code>#include &lt;boost/python.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  
  class token {
      public:
      typedef boost::shared_ptr&lt;token&gt; ptr_type;
  
      static std::vector&lt;std::string&gt; empty_context;
      static std::string empty_center;
  
      token(std::string&amp; t = empty_center,
              std::vector&lt;std::string&gt;&amp; left = empty_context,
              std::vector&lt;std::string&gt;&amp; right = empty_context)
          : center(t), left_context(left), right_context(right) {}
      virtual ~token(void)  {}  
  
      std::vector&lt;std::string&gt; left_context;
      std::vector&lt;std::string&gt; right_context;
      std::string center;
  };
  
  std::string token::empty_center;
  std::vector&lt;std::string&gt; token::empty_context;
  </code></pre>
  
  <p>exposed to python via</p>
  
  <pre><code>BOOST_PYTHON_MODULE(test) {
      namespace bp = boost::python;
      bp::class_&lt;token, token::ptr_type&gt;("token")
      .def(bp::init&lt;std::string&amp;, bp::optional&lt;std::vector&lt;std::string&gt;&amp;,
              std::vector&lt;std::string&gt;&amp;&gt; &gt;())
      ;   
  }
  </code></pre>
  
  <p>then, when trying to use it in python:</p>
  
  <pre><code>Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; from test import token
  &gt;&gt;&gt; word = 'aa'
  &gt;&gt;&gt; t = token(word)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  Boost.Python.ArgumentError: Python argument types in
      token.__init__(token, str)
  did not match C++ signature:
      __init__(_object*, std::string {lvalue})
      __init__(_object*, std::string {lvalue}, std::vector&lt;std::string,     std::allocator&lt;std::string&gt; &gt; {lvalue})
      __init__(_object*, std::string {lvalue}, std::vector&lt;std::string,     std::allocator&lt;std::string&gt; &gt; {lvalue}, std::vector&lt;std::string, std::allocator&lt;std::string&gt;     &gt; {lvalue})
      __init__(_object*)
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Can anyone point me to where this comes from? Shouldn't Boost.Python take care of converting python's <code>str</code> to <code>std::string</code>?</p>
  
  <p>Versions of software/libraries involved:</p>
  
  <pre><code>Boost version: 1.46.1
  Python version: 2.7.2
  Compiler: g++ (SUSE Linux) 4.6.2
  Makefile generation: cmake version 2.8.6
  Make: GNU Make 3.82
  </code></pre>