Hi -
Using Boost 1.53.0, the following code fails to compile with g++, when
c++11 is enabled:

#include <boost/python.hpp>
#include <boost/variant.hpp>

struct A{}; struct B{};

typedef boost::variant<A, B> my_variant;

void foo(boost::python::object o) {
    my_variant v = boost::python::extract<my_variant>(o);
}

The error is:
/home/bcatanzaro/boost_1_53_0/boost/variant/variant.hpp:1574:9: error: no
matching function for call to ‘boost::variant<A,
B>::initializer::initialize(void*,
std::remove_reference<boost::python::extract<boost::variant<A, B>
>&>::type)’

Looking at the relevant line in boost/variant/variant.hpp, it looks like
variant is attempting to convert the boost::python::extract<my_variant>
object into either A or B, and failing to find a conversion. Since this
code compiles when c++11 is not enabled, it appears rvalue references
coupled with boost::python::extract are confusing boost::variant's
constructor selection; I would expect it should be copy constructing from
variant<A, B>, rather than convert constructing into A or B.

Any advice or workarounds? Turning off c++11 is difficult, since the whole
project relies on it. The code compiles correctly with c++11 turned on with
Boost 1.48.0, so it appears something has regressed.

Thanks,
bryan
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to