From joker.eph at gmail.com Sat Apr 19 09:27:18 2014 From: joker.eph at gmail.com (Mehdi AMINI) Date: Sat, 19 Apr 2014 00:27:18 -0700 Subject: [C++-sig] Fail to initialize boost::python::object with a class with an overloaded operator& Message-ID: <53522556.9020209@gmail.com> Hi, Possibly related but old: https://mail.python.org/pipermail/cplusplus-sig/2005-October/009304.html Trying to create a boost::python::object with an instance of a class that has a "crazy" operator& fails here: boost/python/converter/arg_to_python.hpp:209:9: error: no matching constructor for initialization of 'boost::python::converter::detail::arg_to_python_base' : arg_to_python_base(&x, registered::converters) Replacing "&x" with "addressof(x)" solve the issue, if you don't see any drawback I suggest it could be changed in the next release :) Note: I know that overloading wildy the operator& is considered as bad, but my sample code seems quite "standard": std::vector v { true }; boost::python::object b_(v[0]); It fails when compiling with libc++ as they handle (the infamous) std::vector in a (non standard) way similar as std::bitset and provided a class to wrap reference to element of the vector. This __bit_reference overloads the operator& to return a __bit_iterator, which breaks boost::python::object initialization. The trace is: include/boost/python/converter/arg_to_python.hpp:256:7: note: in instantiation of member function 'boost::python::converter::detail::value_arg_to_python >, true> >::value_arg_to_python' requested here : base(x) ^ include/boost/python/object_core.hpp:393:33: note: in instantiation of member function 'boost::python::converter::arg_to_python >, true> >::arg_to_python' requested here return python::incref(converter::arg_to_python(x).get()); ^ include/boost/python/object_core.hpp:312:10: note: in instantiation of function template specialization 'boost::python::api::object_initializer_impl::get >, true> >' requested here >::get( ^ include/boost/python/object_core.hpp:334:23: note: in instantiation of function template specialization 'boost::python::api::object_base_initializer >, true> >' requested here : object_base(object_base_initializer(x)) ^ helloworld.cpp:28:25: note: in instantiation of function template specialization 'boost::python::api::object::object >, true> >' requested here boost::python::object b_(v[0]); ^ include/boost/python/converter/arg_to_python_base.hpp:20:7: note: candidate constructor not viable: no known conversion from '__bit_iterator >, false>' to 'const volatile void *' for 1st argument arg_to_python_base(void const volatile* source, registration const&); ^ Best, Mehdi