[C++-sig] Dissimilar Overloads

Scott A. Smith ssmith at magnet.fsu.edu
Wed Dec 4 18:50:12 CET 2002


Hi,

If one has overloaded functions with dis-similar arguments,
do they need to be wrapped separately? While I have been able
to successfully use BOOST_PYTHON_FUNCTION_OVERLOADS and
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS when my functions have
argument lists that are similar and/or use default values, I cannot
figure out how to do something equally simple to get functions with
different types of arguments exported. For example, is there something
like the code below that can work?

#include <boost/python/def.hpp>
using namespace boost::python;

int f(int x, int y, int z);
void f(double d, complex z);

BOOST_PYTHON_MODULE(xxx)
{
   def("f", f, args("x", "y", "z"));
   def("f", f, args("d", "y"));
}

Or do I have to define new functions with different names
then export them?

Thanks,
Scott





More information about the Cplusplus-sig mailing list