[C++-sig] how to disambiguate 2 overloaded mem funs each with just 1 arg

DRandallTaylor DRandallTaylor at yahoo.com
Sat Apr 1 19:31:49 CEST 2006


Hello,
N00bie here.
How do I disambiguate 2 member functions each having just 1 arg:

struct C
{
   int len(const char* const val) { return ::strlen(val); }
   int len(const std::string &val) { return val.size(); }
};
BOOST_PYTHON_MODULE(pycore)
{
  boost::python::class_<C>("C")
   .def("len"
        , &C::len
        , boost::python::return_value_policy< python::return_by_value >()
   );
}

There must be some way to tell boost::python that when I pass a python str 
object to C::len then convert the arg to a "const char* const" and call the 
first overload of C::len.  (I told you this was going to be easy! But not for 
me because I'm n00b.).

Cheers,
DRandallTaylor











More information about the Cplusplus-sig mailing list