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<T>::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<bool> v { true };
boost::python::object b_(v[0]);
It fails when compiling with libc++ as they handle (the infamous)
std::vector<bool> 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<std::__1::__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> >, 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<std::__1::__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> >, true> >::arg_to_python' requested here
return python::incref(converter::arg_to_python<T>(x).get());
^
include/boost/python/object_core.hpp:312:10: note: in instantiation of
function template specialization
'boost::python::api::object_initializer_impl<false,
false>::get<std::__1::__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> >, 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<std::__1::__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> >, 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<std::__1::__bit_reference<std::__1::vector<bool,
std::__1::allocator<bool> >, 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<std::__1::vector<bool, std::__1::allocator<bool> >,
false>' to 'const volatile void *' for 1st argument
arg_to_python_base(void const volatile* source, registration const&);
^
Best,
Mehdi
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig