[C++-sig] init from free function instead of constructor
John Reid
j.reid at mail.cryst.bbk.ac.uk
Wed Jan 24 22:57:47 CET 2007
John Reid wrote:
> Well it returns by value as in the example. I shall have a look at the
> call policies documentation.
>
Ok so by-value should be handled by the default call policies if the
documentation is right.
I have checked with a minimal test case that I get the same errors:
class X { };
X make_x( const std::string & ) { return X(); }
void export_x()
{
using namespace boost::python;
class_< X > x( "X" );
x.def( "__init__", make_constructor( make_x ) );
}
gives me:
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(28) :
error C2039: 'element_type' : is not a member of 'X'
python_transfac.cpp(24) : see declaration of 'X'
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(38) :
see reference to class template instantiation
'boost::python::detail::pointee_impl<false>::apply<T>' being compiled
with
[
T=X
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/make_constructor.hpp(54)
: see reference to class template instantiation
'boost::python::pointee<T>' being compiled
with
[
T=X
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/make_constructor.hpp(39)
: see reference to function template instantiation 'void
boost::python::detail::install_holder<T>::dispatch<T>(Ptr,boost::mpl::false_)
const' being compiled
with
[
T=result_t,
Ptr=result_t
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/make_constructor.hpp(38)
: while compiling class template member function 'PyObject
*boost::python::detail::install_holder<T>::operator ()(T) const'
with
[
T=result_t
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/detail/caller.hpp(196)
: see reference to class template instantiation
'boost::python::detail::install_holder<T>' being compiled
with
[
T=result_t
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/detail/caller.hpp(176)
: while compiling class template member function 'PyObject
*boost::python::detail::caller_arity<1>::impl<F,Policies,Sig>::operator
()(PyObject *,PyObject *)'
with
[
F=X (__cdecl *)(const std::string &),
Policies=inner_policy,
Sig=boost::mpl::vector2<X,const std::string &>
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/detail/caller.hpp(145)
: see reference to class template instantiation
'boost::python::detail::caller_arity<1>::impl<F,Policies,Sig>' being
compiled
with
[
F=X (__cdecl *)(const std::string &),
Policies=inner_policy,
Sig=boost::mpl::vector2<X,const std::string &>
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/make_constructor.hpp(152)
: see reference to class template instantiation
'boost::python::detail::caller<F,CallPolicies,Sig>' being compiled
with
[
F=X (__cdecl *)(const std::string &),
CallPolicies=inner_policy,
Sig=boost::mpl::vector2<X,const std::string &>
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/make_constructor.hpp(230)
: see reference to function template instantiation
'boost::python::api::object
boost::python::detail::make_constructor_aux<X(__cdecl *)(const
std::string
&),boost::python::default_call_policies,boost::mpl::vector2<T0,T1>>(F,const
CallPolicies &,const Sig &)' being compiled
with
[
T0=X,
T1=const std::string &,
F=X (__cdecl *)(const std::string &),
CallPolicies=boost::python::default_call_policies,
Sig=boost::mpl::vector2<X,const std::string &>
]
python_transfac.cpp(30) : see reference to function template
instantiation 'boost::python::api::object
boost::python::make_constructor<X(__cdecl *)(const std::string &)>(F)'
being compiled
with
[
F=X (__cdecl *)(const std::string &)
]
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(28) :
error C2146: syntax error : missing ';' before identifier 'type'
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(28) :
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(28) :
error C2208: 'boost::type' : no members defined using this type
C:\Dev\ThirdParty\boost\RC_1_34_0\boost\boost/python/pointee.hpp(28) :
fatal error C1903: unable to recover from previous error(s); stopping
compilation
so I'm stuck :(
John.
More information about the Cplusplus-sig
mailing list