Dan Nuffer <[EMAIL PROTECTED]> writes: > David Abrahams wrote: >> 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 ;-) >> } >> > > You probably know something I don't.
Don't count on it ;-) > 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? I don't really know. I guess it depends on what your format function needs to do. Can you build an appropriate function with the raw Python/C API? If so, I can show you how to use it with Boost.Python. -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost