[C++-sig] indexing suite and std::vector<std::string>

Johan Rydberg jrydberg at gnu.org
Sat Nov 11 23:49:23 CET 2006


Hi,

One of the methods I wrap return a std::vector<std::string>, which
needs to be wrapped as well.  I was told about the indexing suite and
gave it a try;

  class_<vector<string> >("std_string_vec")
    .def (vector_indexing_suite<vector<string> > ());

With the following result;

  >>> repr(x)
  '<std_string_vec object at 0xb7e37d2c>'
  >>> len(x)
  5
  >>> x[0]
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  TypeError: No Python class registered for C++ class std::string

I was under the impression that strings should be magically wrapped by
boost.python.  Any ideas anyone?

~j
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20061111/9a254105/attachment.pgp>


More information about the Cplusplus-sig mailing list