[C++-sig] Function Overload Problems
Scott A. Smith
ssmith at magnet.fsu.edu
Thu Nov 14 19:06:28 CET 2002
Try as I might, I still cannot get function overloading to work.
Here is an example that I hope someone can correct:
struct X {
std::string Xstr;
X() {}
void myname(const std::string& N)
{ Xstr = N; }
std::string myname(double xx) const
{ xx += 3.0; return Xstr; }
std::string myname() const
{ return Xstr; }
};
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Xname, myname, 0, 1)
BOOST_PYTHON_MODULE(MyModule)
{
class_<X>("X")
.def("name", ( void(X::*) (const std::string&) )0,
Xname())
.def("name", (std::string(X::*) (double) const)0,
Xname())
.def("name", (std::string(X::*) () const)0,
Xname())
;
}
The first two work fine, the last one does not. What is wrong with this?
Is this the right way to use BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS? Is
there an alternative way of doing exposing these overladed functions?
Thanks,
Scott
More information about the Cplusplus-sig
mailing list