/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_MEMORY_POINTER_CAST_HPP #define SPROUT_MEMORY_POINTER_CAST_HPP #include #include #include #include namespace sprout { // // static_pointer_cast // const_pointer_cast // dynamic_pointer_cast // reinterpret_pointer_cast // template inline SPROUT_CONSTEXPR T* static_pointer_cast(U* p) { return static_cast(p); } template inline SPROUT_CONSTEXPR T* const_pointer_cast(U* p) { return const_cast(p); } template inline SPROUT_CONSTEXPR T* dynamic_pointer_cast(U* p) { return sprout::dyn_cast(p); } template inline SPROUT_CONSTEXPR T* reinterpret_pointer_cast(U* p) { return sprout::reinter_cast(p); } #if !defined(SPROUT_NO_CXX11_SMART_PTR) template inline SPROUT_NON_CONSTEXPR std::shared_ptr static_pointer_cast(std::shared_ptr const& p) { return std::static_pointer_cast(p); } template inline SPROUT_NON_CONSTEXPR std::shared_ptr const_pointer_cast(std::shared_ptr const& p) { return std::const_pointer_cast(p); } template inline SPROUT_NON_CONSTEXPR std::shared_ptr dynamic_pointer_cast(std::shared_ptr const& p) { return std::dynamic_pointer_cast(p); } template inline SPROUT_NON_CONSTEXPR std::shared_ptr reinterpret_pointer_cast(std::shared_ptr const& p) { typedef typename std::shared_ptr::element_type element_type; return std::shared_ptr(p, reinterpret_cast(p.get())); } #endif } // namespace sprout #endif // #ifndef SPROUT_MEMORY_POINTER_CAST_HPP