[C++-sig] Re: Injected constructors

David Abrahams dave at boost-consulting.com
Wed Jul 23 19:12:04 CEST 2003


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> --- David Abrahams <dave at boost-consulting.com> wrote:
>>           .def("__init__", init_factory(x_factory))
>
> I don't like the "init" duplication. Would this be possible?
>
> .def(init_factory(x_factory))

yes.

> This would also make sense to me:
>
> .def("__init__", factory(x_factory))
>
> But I like the first alternative better because it is more formal
> and prevents frustrating debugging sessions due to stupid typos
> like .def("_init__", factory(x_factory)).
>
> Yet another idea:
>
> .def_factory(x_factory)
>
> It means expanding the class_<> interface, but I think the purpose
> is unique enough to warrant the additional member function.

Actually, we're trying to avoid bloating it even more.  Joel is about
to commit a simple mechanism which even allows us to move the
pickle_suite functionality out of class_.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list