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::object(A::static_a); // [1]
  return *result;
}

Wrapping A and static_instance with Boost.Python is no problem, and
everything works as expected, however the A::static_a that is being
passed to bp::object() at [1] is being copied, which defeats the whole
purpose.

Anybody has an idea how achieve this? Thanks!

Cheers

Michael
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to