mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-31 13:17:23 +02:00
Add overloads for std::shared_ptr to pointer casts
This commit is contained in:
@ -42,4 +42,34 @@ inline T* reinterpret_pointer_cast(U *ptr)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_SMART_PTR )
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//static_pointer_cast overload for std::shared_ptr
|
||||
using std::static_pointer_cast;
|
||||
|
||||
//dynamic_pointer_cast overload for std::shared_ptr
|
||||
using std::dynamic_pointer_cast;
|
||||
|
||||
//const_pointer_cast overload for std::shared_ptr
|
||||
using std::const_pointer_cast;
|
||||
|
||||
//reinterpret_pointer_cast overload for std::shared_ptr
|
||||
template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) BOOST_NOEXCEPT
|
||||
{
|
||||
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
|
||||
|
||||
typedef typename std::shared_ptr<T>::element_type E;
|
||||
|
||||
E * p = reinterpret_cast< E* >( r.get() );
|
||||
return std::shared_ptr<T>( r, p );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined( BOOST_NO_CXX11_SMART_PTR )
|
||||
|
||||
#endif //BOOST_POINTER_CAST_HPP
|
||||
|
Reference in New Issue
Block a user