[C++-sig] Re: boost::python: wrap std::string?

David Abrahams dave at boost-consulting.com
Wed May 26 16:35:33 CEST 2004

"paul.bridger" <paul.bridger at paradise.net.nz> writes:

> Okay, hopefully someone can tell me what I'm doing wrong here.
> I am trying to wrap a class that derives from std::string. Everything
> seems to go just fine until I try to import the derived class in
> Python. This is the error message I get:
> RuntimeError: extension class wrapper for base class class
> std::basic_string<char,struct std::char_traits<char>,class
> std::allocator<char> > has not been created yet
> What is my best course of action?

Get Pyste not to list std::basic_string in your class' list of
bases<...>.  But then, you'll need to explicitly expose all of the
base class interface from std::string that you want to use.  

It's genterally a bad idea to derive from std::string, but I suppose
this library you're trying to wrap isn't giving you a choice.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list