David Abrahams wrote:
You probably know something I don't. I can't think of a way to do this without having a n^m explosion of code, where n = number of types to support and m = number of arguments. Is there an good way to implement this?Dan Nuffer <[EMAIL PROTECTED]> writes:2. Is is possible to wrap member functions which take a variable number of arguments (e.g. int format(const char* fmt, ...); ) ? I tried .def("format", &OW_String::format) but that doesn't work.
Not directly. Conversions from Python to C++ are "target-driven",
meaning that we need to know the type of the C++ argument in order to
make the conversion happen.
There are ways you can write a function which takes an arbitrary
number of Python objects in an argument tuple, and you can do the
dispatching yourself.
You could also consider supporting a fixed maximum number of arguments
by wrapping something like:
int format_dispatch(
char const*fmt, object a0 = object(), object a1 =
object()... object aN = object())
{
// implementation details left up to you ;-)
}
Thanks,
Dan Nuffer
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost