[C++-sig] Trouble wrapping a function returning a pointer to a class.

David Abrahams dave at boost-consulting.com
Mon Apr 21 16:07:06 CEST 2003


tALSit de CoD <talsit at talsit.org> writes:

> I'm very very very new to this boost.python, so i might probably be
> looking in all the wrong places.
>
> I have a class and a function:
>
> namespace kikura {
>          class cKernel { ... };
>          cKernel * getKikuraKernel ();
> } // namespace kikura
>
> and I want to wrap it like so:
>
> namespace kikura {
>          BOOST_PYTHON_MODULE (kikura) {
>                  class_ <cKernel> ("cKernel", init<std::string>());
>                  def ("getKikuraKernel", getKikuraKernel);
>          }
>
> } // namespace kikura
>
> And it barfs at me with this error:
> d:\data\users\tALSit\code\c.c++\usr\boost\boost\python\detail\invoke.hpp(80)
> : error C2514:
> 'boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<T>'
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : class has no constructors

Note that it probably also says:

     T = cKernel*

See

http://www.boost.org/libs/python/doc/tutorial/doc/call_policies.html

for a description of call policies.  Please also read the reference
documentation at

http://www.boost.org/libs/python/doc/v2/reference.html#models_of_call_policies

and

http://www.boost.org/libs/python/doc/v2/reference.html#result_converter_generators

before attempting to use them; people often choose the wrong policy
until they understand all of the options.

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





More information about the Cplusplus-sig mailing list