[C++-sig] wrapping objects which inherit from std::map

Jeremy Kie jeremykie at gmail.com
Wed May 6 19:44:18 CEST 2009


Thanks for the direction Stefan.

Apologies for the typos. What I was missing was the declaration of the
"std::map" prior to my foo declaration.  Yes, I agree with you regarding
derivation from standard containers.  My portion of the project is written
in python, I'm trying to work with libraries written by another member of
the team.

With the addition of the "std::map" declaration, my compiler errors
disappeared.

Thanks,

Jeremy


On Wed, May 6, 2009 at 11:29 AM, Stefan Seefeld <seefeld at sympatico.ca>wrote:

> Jeremy Kie wrote:
>
>> Hi,
>>
>> I have the following:
>>
>> class foo : public std::map<std::string, std::string> {
>> }
>>
>
> You lack a semicolon here. (I also don't think it's a good idea to derive
> from standard containers, but that is an entirely different subject).
>
>
>> BOOST_PYTHON_MODULE(foo_ext)
>> {
>>  using namespace boost::python;
>>  class_<foo, bases<std::map>>("foo");
>>
>
> There are three errors here, let's start with the simplest:
>
> You use '>>' in this line, which is a single token. You need to insert a
> whitespace there to make it two tokens, e.g. '> >'.
> Next, you use 'std::map' where you ought to use a type (such as
> 'std::map<std::string, std::string>'.
> Finally, you only can declare bases that are themselves already exported to
> python via class_, so you need to start by exporting the base type
> std::map<std::string, std::string> prior to 'foo'.
>
> Hope this helps,
>      Stefan
>
>
> --
>
>     ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090506/7e1ec1c6/attachment.htm>


More information about the Cplusplus-sig mailing list