[C++-sig] FW: boost.python internal references on basic types

English, Mark Mark.English at rbccm.com
Tue Jun 17 15:22:30 CEST 2008


> -----Original Message-----
> From: c++-sig-bounces at python.org 
> [mailto:c++-sig-bounces at python.org] On Behalf Of Renaud Lepere
> Sent: 17 June 2008 13:52
> To: c++-sig at python.org
> Subject: [C++-sig] boost.python internal references on basic types
> 
> 
> Here is my simplified example 
> 
> class Foo
> {
> public:
>     void set_x(int & x) { m_x = x;}
>     const int & get_x() { return m_x; }
>     int m_x;
> };
> BOOST_PYTHON_MODULE(hello)
> {
>    class_<Foo>("Foo")
>        .def("set_x", &Foo::set_x)
>        .def("get_x", &Foo::get_x, 
>              return_internal_reference< >() )
>        ;
> }
> 
> If I replace "int" with a proxy class containing the int 
> everything is ok ; but I would prefer not to change the c++ code.
> 
> Can someone have an idea if what I try to do is possible ?

Remove the "return_internal_reference". Trying to share int references
isn't something Python supports without adding additional hand-crafted
wrapper code.
_______________________________________________________________________

This email is intended only for the use of the individual(s) to whom
it is addressed and may be privileged and confidential.

Unauthorised use or disclosure is prohibited. If you receive this
e-mail in error, please advise immediately and delete the original
message without copying, using, or telling anyone about its contents.

This message may have been altered without your or our knowledge and
the sender does not accept any liability for any errors or omissions
in the message.

This message does not create or change any contract.  Royal Bank of
Canada and its subsidiaries accept no responsibility for damage caused
by any viruses contained in this email or its attachments.  Emails may
be monitored.

RBC Capital Markets is a business name used by branches and
subsidiaries of Royal Bank of Canada, including Royal Bank of Canada,
London branch and Royal Bank of Canada Europe Limited. In accordance
with English law requirements, details regarding Royal Bank of Canada
Europe Limited are set out below:

ROYAL BANK OF CANADA EUROPE LIMITED
Registered in England and Wales 995939
Registered Address: 71 Queen Victoria Street, London, EC4V 4DE.
Authorised and regulated by the Financial Service Authority.
Member of the London Stock Exchange




More information about the Cplusplus-sig mailing list