Share pointer of a local object.Use this wrapper when an interface needs a shared_ptr, but you want to pass an object that has local storage (and you know that the shared_ptr client doesn't need it outside of the scope).
Foo obj;
std::shared_ptr <Foo> ptr = share_obj (obj);
#ifndef OPM_SHARE_OBJ_HPP
#define OPM_SHARE_OBJ_HPP
#include <memory>
inline void no_delete (void const *) { }
template <typename T> std::shared_ptr <T> share_obj (T& t) {
return std::shared_ptr <T> (&t, no_delete);
}
}
#endif