Re: [C++-sig] Wrapping a non-copyiable static instance in bp::object

2013-01-20 Thread Michael Wild
I knew (hoped, really) there would be a simple solution! Thanks, it works beautifully. Michael PS: Sorry, I posted earlier, but didn't notice that I got rejected because I used the wrong sender address... On 01/16/2013 10:29 PM, Wojciech Mamrak wrote: > Hi, > > bp::object static_instance() > {

Re: [C++-sig] Wrapping a non-copyiable static instance in bp::object

2013-01-16 Thread Wojciech Mamrak
Hi, bp::object static_instance() { static bp::object* result = new bp::object(boost::ref(A::static_a)); return *result; } Instead of exposing a function static_instance in your module, you can alternatively add a variable to your module's scope: scope sc; sc.attr("static_a") = boost::ref(A::

[C++-sig] Wrapping a non-copyiable static instance in bp::object

2013-01-16 Thread Michael Wild
Dear all I struggle to find a way in which I can wrap a static instance in a bp::object without copying it. The goal is to have object identity for this static instance: struct A { /*...*/ static A static_a; }; a A::a; bp::object static_instance() { static bp::object* result = new bp::obj