[C++-sig] A couple of simple BP V2 questions

Scott A. Smith ssmith at magnet.fsu.edu
Wed Nov 13 19:54:20 CET 2002


Hi Joel,

> No, not really. You can still use the overloads mechanism without
> using thin wrappers for overloads with different signatures. You'll
> just need another BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
> call for each set of overload signature.
>
> See boost/libs/python/defaults.cpp for examples.

Just be be clear. In boost/libs/python/test/defaults.cpp there is

1.) struct X with member functions:

    object foo(int a,          bool b=false) const
    object foo(std::string a,  bool b=false) const
    object foo(list a, list b, bool c=false) const

2.) BP overloading

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_foo_2_stubs, foo, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_foo_3_stubs, foo, 2, 3)

3.) BP function exports

        .def("foo", (object(X::*)(std::string, bool) const)0,
X_foo_2_stubs())
        .def("foo", (object(X::*)(int,         bool) const)0,
X_foo_2_stubs())
        .def("foo", (object(X::*)(list, list, bool)  const)0,
X_foo_3_stubs())

which helps out a lot in clarifying things. Use of .def here deviates quite
a
bit from that shown in the tutorial (anywhere), but I guess you can't show
everything.
What is the 0 following const) in the above three lines for? I cannot find
this even
in the reference manual.

Scott





More information about the Cplusplus-sig mailing list