[C++-sig] [Boost.Python] map_indexing_suite problem
Jan Langer
jan at langernetz.de
Tue Nov 22 14:07:06 CET 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joel de Guzman wrote:
>>>I ran into a problem with Boost.Python exporting a std::map. I used the
>>>following code below. I use Boost 1.33.0 and everything compiles fine.
>>
>>Have you tried setting NoProxy template parameter to true?
>>
>> class_ <map_t, true> ("test_map")
>
> This is the same issue as discussed in:
> http://mail.python.org/pipermail/c++-sig/2004-March/007029.html
>
> I've just added a fix for this that regards std::string and
> std::complex as no-proxy types.
Hello,
I tried setting NoProxy to true and it worked in the example I posted.
However my real example is a little more complicated. I copied the
relevant part below:
struct domain
{};
struct graph
{
typedef std::map <int, boost::shared_ptr <domain> > domains_t;
domains_t domains_;
};
class_<domain, boost::shared_ptr <domain> > ("domain");
// objects::class_value_wrapper <boost::shared_ptr<domain>,
// objects::make_ptr_instance <domain,
// objects::pointer_holder <boost::shared_ptr<domain>, domain> > > ();
class_<graph::domains_t> ("domains_map")
.def (map_indexing_suite<graph::domains_t, true> ());
class_<graph> ("graph")
.def_readonly ("domains", &graph::domains_);
This code (used in a module called pdg) can be compiled and imported in
Python:
import pdg
g = pdg.graph ()
for el in g.domains:
print el.key(),
dom = el.data()
But the last line gives an error:
TypeError: No Python class registered for C++ class
Q25boostt10shared_ptr1ZQ23pdg6domain
If I comment out the three lines with class_value_wrapper (I saw
something like that in the examples) and remove shared_ptr from the
class_ definition of domain, I get the same error.
I hope that makes my problem clearer.
Regards,
Jan Langer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (SunOS)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDgxf5yJOS3PG4wcwRAjrgAJ9obR9b3g/YA21d4qr8yLH3pMx2SwCgpCQY
eXHTX+NCzzMWSpRdHdgLoIk=
=vFO5
-----END PGP SIGNATURE-----
More information about the Cplusplus-sig
mailing list