Boost logo

Boost :

From: rwgk_at_[hidden]
Date: 2001-08-16 17:55:18


--- In boost_at_y..., John Hunter <jdhunter_at_a...> wrote:
> That works perfectly for me. Do you have a similarly clever trick
for
> classes with several constructors, each of which takes (the same)
> optional argument as the last arg?
>
> class SomeClass {
> public:
> SomeClass( int i = 5) { ... }
> SomeClass( const string& s, int i = 5) { ... }
> SomeClass( const string& s1, const string& s2, int i = 5) { ... }
> };

Maybe I am missing something, but I believe that it is
straight-forward to do what you want:

py_SomeClass.def(boost::python::constructor<>());
py_SomeClass.def(boost::python::constructor<int>());
py_SomeClass.def(boost::python::constructor<const string&>());
py_SomeClass.def(boost::python::constructor<const string&, int>());
py_SomeClass.def(boost::python::constructor<const string&, const
string&>());>());
py_SomeClass.def(boost::python::constructor<const string&, const
string&, int>());

Ralf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk