[C++-sig] constructor wrappers?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri May 31 08:23:43 CEST 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> > Then what next? Do we have to build a bridge from boost::tuple<A1,...>
> > to boost::python::args<A1,...>, or copy-and-paste the processing
> > of args<> and then customize the code for dealing with boost::tuple<>?
> 
> I don't think I'm ready to figure out the entire implementation in
> this email ;-)

Oh, too bad. I thought I could start using the new feature before the
weekend :-)

Here is another idea:

  boost::python::module("any")

    .def("hello", custom_hello_factory)
    
    .add(boost::python::class_<hello>("hello")
      .def_init(boost::python::args<>())
      .def("foo", foo)
      )
  ;

This compiles and I can still instantiate any.hello(), but the
custom_hello_factory is not accessible ("TypeError: bad argument type
for built-in operation"). As I understand, you have overload resolution
for

  - module level functions
  - constructors for a given class name
  - member functions of a given class

Would it be possible to put module level functions and constructors into
one pool? The functions and constructors could be tried in the order in
which they are def'ed or add'ed. If that cannot easily be done, try the
module level functions first, then the regular constructors.
What do you think about this?
Ralf


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Cplusplus-sig mailing list