[C++-sig] injected constructor with a docstring?

Nick Rasmussen nick at ilm.com
Thu Apr 29 21:54:27 CEST 2004


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()")
        ;
}

results in (using gcc-3.3.2):

XXX/boost/python/object_core.hpp: In member function `void boost::python::api::object_operators<U>::visit(ClassT&, const char*, const boost::python::detail::def_helper<DocStringT, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>&) const [with ClassT = boost::python::class_<C, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, DocStringT = char[9], U = boost::python::api::object]':
XXX/boost/python/def_visitor.hpp:44:   instantiated from `static void boost::python::def_visitor_access::visit(const V&, classT&, const char*, const OptionalArgs&) [with V = boost::python::def_visitor<boost::python::api::object>, classT = boost::python::class_<C, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, OptionalArgs = boost::python::detail::def_helper<char[9], boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>]'
XXX/boost/python/def_visitor.hpp:75:   instantiated from `void boost::python::def_visitor<DerivedVisitor>::visit(classT&, const char*, const OptionalArgs&) const [with classT = boost::python::class_<C, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, OptionalArgs = boost::python::detail::def_helper<char[9], boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, DerivedVisitor = boost::python::api::object]'
XXX/boost/python/class.hpp:488:   instantiated from `void boost::python::class_<T, X1, X2, X3>::def_impl(const char*, LeafVisitor, const Helper&, const boost::python::def_visitor<Visitor>*) [with Helper = boost::python::detail::def_helper<char[9], boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, LeafVisitor = boost::python::api::object, Visitor = boost::python::api::object, T = C, X1 = boost::python::detail::not_specified, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]'
XXX/boost/python/class.hpp:571:   instantiated from `void boost::python::class_<T, X1, X2, X3>::def_maybe_overloads(const char*, Fn, const A1&, ...) [with Fn = boost::python::api::object, A1 = char[9], T = C, X1 = boost::python::detail::not_specified, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]'
test_boost.C:304:   instantiated from `boost::python::class_<T, X1, X2, X3>& boost::python::class_<T, X1, X2, X3>::def(const char*, A1, const A2&) [with A1 = boost::python::api::object, A2 = char[9], T = C, X1 = boost::python::detail::not_specified, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]'
test_boost.C:16:   instantiated from here
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?

-nick





More information about the Cplusplus-sig mailing list