Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Python] Wrapping a heterogeneous container
From: Mario Lang (mlang_at_[hidden])
Date: 2014-02-08 16:11:59


Hi.

I have finally figured out how to (mostly) wrap a container of
boost::variant<> in boost::python:

http://blind.guru/boost_python-and-boost_variant.html

The only problem left is the fact that I have to disable the use
of reference semantics (proxies) in vector_indexing_suite.

If I pass false for the NoProxy template parameter of
vector_indexing_suite<>, I can no longer dereference container elements:

>>> import bpv
>>> bpv.make_vector()[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: No Python class registered for C++ class boost::variant<a, b, boost::detail::variant::void_, ...>

However, I have a converter registered with to_python_converter<> that
handles extracting the proper Python object from a variant. This works
if NoProxy is true. However, if NoProxy is true, container elements do
not have reference semantics, so in-place modifications will be lost.

To me, it also looks like the TypeError raise above is sort
of bogus, since I actually used to_python_converter to register
conversion for this particular type. So I guess there are different
types of registries involved, but the message does not indicate which
registry is did refer to.

Does anyone know if I can enable reference semantics for a heterogeneous
container wrapped with indexing_suite?

-- 
CYa,
  ⡍⠁⠗⠊⠕

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net