Boost logo

Boost Users :

Subject: [Boost-users] Overloading errors
From: A B (python6009_at_[hidden])
Date: 2009-04-17 20:25:14


Does anyone know why the following sample fails (it was adapted from
the boost overloading example) and how to do this correctly. Thanks in
advance.

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/args.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/class.hpp>
#include <boost/python/overloads.hpp>
#include <boost/python/return_internal_reference.hpp>

using namespace boost::python;

struct X

{

    int f(int x, double y = 4.25, char const* z = "wow")

    {

        return x;

    }

    int f(int x, bool b = true) {

        return x;

    }

};

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_member_overloads, X::f, 1, 3)

BOOST_PYTHON_MODULE(args_ext)

{

    class_<X>("X", "This is X's docstring")

        .def("f1", &X::f,

             f_member_overloads(args("x", "y", "z"), "f's docstring"

                                )[return_internal_reference<>()]

             )

        ;

}

g++ -fpic -shared -o test.so test.cpp -lpython2.4 -lboost_python
-I/usr/include/python2.4

test.cpp: In function ‘void init_module_args_ext()’:

test.cpp:31: error: no matching function for call to
‘boost::python::class_<X, boost::python::detail::not_specified,
boost::python::detail::not_specified,
boost::python::detail::not_specified>::def(const char [3], <unresolved
overloaded function type>,
boost::python::detail::overloads_proxy<boost::python::return_internal_reference<1ul,
boost::python::default_call_policies>, f_member_overloads>)’


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net