[C++-sig] [Py++] call polices newbie questions
Roman Yakovenko
roman.yakovenko at gmail.com
Wed Mar 25 15:07:23 CET 2009
2009/3/25 Michał Nowotka <mmmnow at gmail.com>:
> Hello,
>
> First of all I found that set of return value polices mention in
> boost.python documentation
> (http://www.boost.org/doc/libs/1_38_0/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies):
>
> * reference_existing_object
> * copy_const_reference
> * copy_non_const_reference
> * manage_new_object
>
> is different from those described in Py++ docs():
>
> * return_opaque_pointer.
> * copy_const_reference
> * return_by_value
> * copy_non_const_reference
> * return_internal_reference
http://language-binding.net/pyplusplus/documentation/functions/call_policies/call_policies.html#syntax
Py++ introduces additional call policies for your convenience.
> Secondly, I really don't have any idea which call policy should i
> choose with following method:
>
> class Allel {
>
> public:
>
> (...)
> const Locus* getLocus() const { return locus_; }
> // <--- This generates warning W1050
> private:
>
> (...)
> const Locus* locus_;
>
> };
>
> or generally which policy should be choosen for method with no
> arguments returning pointer-type member of it's class.
Based on information you provided, I would use "return_internal_reference".
I suggest you to read Boost.Python tutorials. It is critical to
understand call policies for successful Boost.Python usage.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list