, , , boost:: shared_ptr < > ( - to shared_ptr, , ). , , , , , .
, , python . (, , ). , main() .
class_<XY, shared_ptr<XY>, boost::noncopyable >("XY",no_init)
.def("getInstance",&XY::getSharedInstance )
.staticmethod("getInstance")
struct NullDeleter
{
void operator()(const void*){}
};
XY& XY::getInstance()
{
static XY in;
return in;
}
shared_ptr<XY> XY::getSharedInstance()
{
return shared_ptr<XY>( &getInstance(), NullDeleter() );
}
sharedInstance python:
shared_ptr<XY> getSharedInstance()
{
return shared_ptr<XY>( &XY::getInstance(), NullDeleter() );
}
class_<XY, shared_ptr<XY>, boost::noncopyable >("XY",no_init)
.def("getInstance",&getSharedInstance )
.staticmethod("getInstance")