[C++-sig] init from free function instead of constructor

Roman Yakovenko roman.yakovenko at gmail.com
Wed Jan 24 19:43:56 CET 2007


On 1/24/07, John Reid <j.reid at mail.cryst.bbk.ac.uk> wrote:
> Hi,
>
> I can't find anything in the documentation that lets me do this:
>
> class X { };
> X make_x( std::string );
>
> using namespace boost::python;
>
> class_<X>(
>         "X",
>         "This is X's docstring.",
>         init<std::string>( make_x ) )
> ;
>
> Is it true that I can only make python __init__ functions from
> constructors as opposed to free functions such as make_x()?

http://www.boost.org/libs/python/doc/v2/make_function.html#make_constructor-spec

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list