[C++-sig] Boost.Python : Return std::string by ref?

Brian O'Kennedy brian.o'kennedy at vicon.com
Thu May 15 12:01:56 CEST 2008


Hi Hans, 

 

Thanks for that, exactly what I wanted! I should have RTFA... :) 

For reference, here is my new binding:

 

class_ < MyOtherClass >("MyOtherClass", "Testing String returned by
const ref")

    .def( "GetName", &MyOtherClass::GetName,
return_value_policy<copy_const_reference>() )

    .def( "SetName", &MyOtherClass::SetName);

 

Thanks, Brian

 

-----Original Message-----
From: c++-sig-bounces+brian.okennedy=omg3d.com at python.org
[mailto:c++-sig-bounces+brian.okennedy=omg3d.com at python.org] On Behalf
Of Hans Meine
Sent: 15 May 2008 10:56
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Boost.Python : Return std::string by ref?

 

Am Donnerstag, 15. Mai 2008 10:07:20 schrieb Brian O'Kennedy:

> Notice that GetName() now returns the string by const reference; this
is

> done in a lot of our c++ code for efficiency sake. To wrap this using

> Boost.Python I do:

> 

> [...]

>       .def( "GetName", &MyOtherClass::GetName,

> return_internal_reference<>() )

 

I'd try copy_const_reference.

 

-- 

Ciao, /  /

     /--/

    /  / ANS

_______________________________________________

C++-sig mailing list

C++-sig at python.org

http://mail.python.org/mailman/listinfo/c++-sig


________________________________________________________________________
This e-mail, and any attachment, is confidential. If you have received it in error, do not use or disclose the information in any way, notify me immediately, and please delete it from your system.
________________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080515/aae4f379/attachment.htm>


More information about the Cplusplus-sig mailing list