[C++-sig] default arguments
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu May 23 19:04:18 CEST 2002
--- David Abrahams <david.abrahams at rcn.com> wrote:
>
> ----- Original Message -----
> From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
>
> > A large fraction of my Boost.Python V1 code consists of this kind of thin
> > wrappers. It is a real nuisance. What is the expected time of arrival for
> the
> > improved support for default arguments? Any chance this happens before
> next
> > week? <wink>
>
> Not much, unless you're going to do it yourself.
What is involved? Do you have an idea for an interface? A while ago I suggested
that the old V1 boost::python::constructor<T1, T2, ...> interface would be a
"good enough" solution. E.g. (old syntax):
void foo(int i, int j=1);
py_some_type.def(foo, boost::python::signature<int>(), "foo");
py_some_type.def(foo, boost::python::signature<int, int>(), "foo");
Hm, I guess that doesn't work for overloaded functions because current C++ does
not support taking a reference to a family of overloads.
How about (please forgive me if the casts are only approximations to the
correct syntax):
void foo(int i, int j=1);
void foo(const std::string& s, int j=1);
py_some_type.def((void (*)(int, int)) foo, boost::python::signature<int>(),
"foo");
py_some_type.def((void (*)(int, int)) foo, boost::python::signature<int,
int>(), "foo");
py_some_type.def((void (*)(const std::string&, int)) foo,
boost::python::signature<const std::string&>(), "foo");
py_some_type.def((void (*)(const std::string&, int)) foo,
boost::python::signature<const std::string&, int>(), "foo");
Something like this would be a good start. It would mean that I could
concentrate the bindings for a function in one.
Thanks,
Ralf
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
More information about the Cplusplus-sig
mailing list