32 #ifndef LVR2_UTIL_CONVERT_SHARED_H_ 33 #define LVR2_UTIL_CONVERT_SHARED_H_ 36 #include <boost/shared_ptr.hpp> 41 template<
class SharedPo
inter>
struct Holder {
44 Holder(
const SharedPointer &p) : p(p) {}
45 Holder(
const Holder &other) :
p(other.p) {}
46 Holder(Holder &&other) :
p(std::move(other.p)) {}
48 void operator () (...) { p.reset(); }
52 template<
class T> std::shared_ptr<T>
to_std_ptr(
const boost::shared_ptr<T> &
p) {
53 typedef Holder<std::shared_ptr<T>> H;
54 if(H *h = boost::get_deleter<H, T>(p)) {
57 return std::shared_ptr<T>(p.get(), Holder<boost::shared_ptr<T>>(
p));
61 template<
class T> boost::shared_ptr<T>
to_boost_ptr(
const std::shared_ptr<T> &
p){
62 typedef Holder<boost::shared_ptr<T>> H;
63 if(H * h = std::get_deleter<H, T>(p)) {
66 return boost::shared_ptr<T>(p.get(), Holder<std::shared_ptr<T>>(
p));
std::shared_ptr< T > to_std_ptr(const boost::shared_ptr< T > &p)
boost::shared_ptr< T > to_boost_ptr(const std::shared_ptr< T > &p)