Nick Rasmussen <nick@ilm.com> writes:
I'm creating an injected constructor for one of my classes, but can't seem to add a docstring to it in the .def:
#include <boost/python.hpp> #include <boost/python/make_constructor.hpp> using namespace boost::python;
class C { public: C(int i, int j, int k) {} };
C * make_C() { return new C(0,0,0); }
BOOST_PYTHON_MODULE(test_boost) { class_<C>("C", "C docstring", init<int,int,int>("doc: C(i,j,ij)")) .def("__init__",make_constructor(make_C),"doc: C()") ; }
<snip>
XXX/boost/python/object_core.hpp:181: error: invalid application of `sizeof' to an incomplete type
removing the "doc: C()" string allows it to compile. I know that I can add it manually later, but is there a way to do it in the .def?
This is a bug in Boost.Python. You can patch your version by replacing BOOST_STATIC_ASSERT( (is_same<char const*,DocStringT>::value || detail::is_string_literal<DocStringT>::value)); with BOOST_STATIC_ASSERT( (is_same<char const*,DocStringT>::value || detail::is_string_literal<DocStringT const>::value)); ^^^^^ at line 181 of boost/python/object_core.hpp -- Dave Abrahams Boost Consulting http://www.boost-consulting.com