Getting a normal ptr from boost::shared_ptr?

Use the get() method:

boost::shared_ptr<foo> foo_ptr(new foo());
foo *raw_foo = foo_ptr.get();
c_library_function(raw_foo);

Make sure that your shared_ptr doesn’t go out of scope before the library function is done with it — otherwise badness could result, since the library may try to do something with the pointer after it’s been deleted. Be especially careful if the library function maintains a copy of the raw pointer after it returns.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)