Ravelin
virtual_enable_shared_from_this.hpp
1 #ifndef _VIRTUAL_SHARED_FROM_THIS_HPP_
2 #define _VIRTUAL_SHARED_FROM_THIS_HPP_
3 
4 #include <boost/shared_ptr.hpp>
5 #include <boost/enable_shared_from_this.hpp>
6 
7 namespace Ravelin {
8 
10  boost::enable_shared_from_this<virtual_enable_shared_from_this_base> {
12 };
13 
14 template<typename T>
17  boost::shared_ptr<T> shared_from_this() {
18  return boost::dynamic_pointer_cast<T>(
19  virtual_enable_shared_from_this_base::shared_from_this());
20  }
21 
22  boost::shared_ptr<const T> shared_from_this() const {
23  return boost::dynamic_pointer_cast<const T>(
24  virtual_enable_shared_from_this_base::shared_from_this());
25  }
26 };
27 
28 }
29 #endif
30 
Definition: virtual_enable_shared_from_this.hpp:9
Definition: virtual_enable_shared_from_this.hpp:15