Robert Bradshaw wrote:
> What about
> 
> cdef CppObject a, b
> a = bar
> b = bar
> del a
> del b
> 
> ?

Actually this *can* be supported by overloading operator new.

I'll change the example to

cdef CppObject a, b
a = CppObject(3)
b = CppObject(4)
del a
del b

to avoid an unrelated and orthogonal issue with operator=. Then you can do:

struct {} CythonOperators;

void* operator new(size_t bytes, char* arg, CythonOperators foo) { 
return arg; }
void operator delete(void* arg, CythonOperators foo) {/*noop*/}

void f() {
   char a[sizeof(CppObject)];
   char b[sizeof(CppObject)];

   new(a, CythonOperators) CppObject(3);
   new(b, CythonOperators) CppObject(4);

   delete(CythonOperators) a;
   delete(CythonOperators) b;
}

And /yes/, this is real C++ code... *sigh* :-) (though I'm not sure if I 
got the details 100% right).

I wouldn't really recommend going this route though.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to