From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2002-11-08 00:57:15
David Abrahams wrote:
> Dan Nuffer <dnuffer_at_[hidden]> 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 ;-)
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk