Auto_ptr with swig?

I do not believe you are going to be able to successfully wrap this code in SWIG. The problem is that auto_ptr changes ownership when it copies. This is why it requires the copy constructor to not have const.

The way that SWIG manages ownership of objects internally means that the it is unlikely you'll get the desired ownership behavior without a lot of custom SWIG code.

I found hint how to do it in libRETS, and you need to do it on per-method basis: code.crt.realtors.org/projects/librets/b... Basically you want to unwrap auto_ptr you receive from C++ and wrap it before passing to C++. Example of code to be put into . I file is: //original prototype: //virtual void SetSomething(std::auto_ptr value) = 0; //replacement to be generated by SWIG: %extend{ void SetSomething(ValueClass *value){ std::auto_ptr tmp(value); $self->SetSomething(tmp); } } //retrieving object wrapped in auto_ptr using swig macro: %define SWIG_RELEASE_AUTO_PTR(RETURN_TYPE, METHOD_NAME, PROTO, ARGS) %extend { RETURN_TYPE * METHOD_NAME PROTO { std::auto_ptr auto_result = self->METHOD_NAME ARGS; return auto_result.release(); } } %enddef // and then inside class: // virtual auto_ptr SomeMethod(const string& foo) = 0; // replaced with: SWIG_RELEASE_AUTO_PTR(ValueClass,SomeMethod,(const string& foo),(foo)).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions