[C++-sig] return_arg
David Abrahams
dave at boost-consulting.com
Wed Aug 3 15:54:16 CEST 2005
"Ira" <sheig222 at gmail.com> writes:
> What I *tried* to do is:
>
> MyClass* pMyClass;
>
> main()
> {
> pMyClass = new MyClass;
> }
>
> MyClass* GetMyClass()
> {
> return pMyClass;
> }
>
> BOOST_PYTHON_MODULE(mymod)
> {
> class_<MyClass>.....
>
> def ("GetMyClass", GetMyClass);
> }
>
> This didn't compile with "C2027 use of unspecified type
> boost::python::detail::specify_a_return_value_to_wrap_functions_returning<T>
> with T=result_t".
You need to specify a return value policy when returning pointers and
references from functions, because otherwise Boost.Python doesn't know
how/whether to manage the lifetime of the thing referred to. In this
case, reference_existing_object looks like the right policy. Since
GetMyClass has no arguments, return_arg certainly can't be the right
choice!
HTH,
Dave
P.S. Next time I suggest you copy/paste your actual code and the actual
error message. It was
specify_a_return_value_policy_to_wrap_functions_returning
^^^^^^^
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list