Brian Silverman | 407d3cd | 2018-08-04 17:48:52 -0700 | [diff] [blame^] | 1 | // Copyright Peter Dimov and David Abrahams 2002. |
| 2 | // Distributed under the Boost Software License, Version 1.0. (See |
| 3 | // accompanying file LICENSE_1_0.txt or copy at |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | #ifndef GET_POINTER_DWA20021219_HPP |
| 6 | #define GET_POINTER_DWA20021219_HPP |
| 7 | |
| 8 | #include <boost/config.hpp> |
| 9 | |
| 10 | // In order to avoid circular dependencies with Boost.TR1 |
| 11 | // we make sure that our include of <memory> doesn't try to |
| 12 | // pull in the TR1 headers: that's why we use this header |
| 13 | // rather than including <memory> directly: |
| 14 | #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr |
| 15 | |
| 16 | namespace boost { |
| 17 | |
| 18 | // get_pointer(p) extracts a ->* capable pointer from p |
| 19 | |
| 20 | template<class T> T * get_pointer(T * p) |
| 21 | { |
| 22 | return p; |
| 23 | } |
| 24 | |
| 25 | // get_pointer(shared_ptr<T> const & p) has been moved to shared_ptr.hpp |
| 26 | |
| 27 | #if !defined( BOOST_NO_AUTO_PTR ) |
| 28 | |
| 29 | #if defined( __GNUC__ ) && (defined( __GXX_EXPERIMENTAL_CXX0X__ ) || (__cplusplus >= 201103L)) |
| 30 | #if defined( BOOST_GCC ) |
| 31 | #if BOOST_GCC >= 40600 |
| 32 | #define BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS |
| 33 | #endif // BOOST_GCC >= 40600 |
| 34 | #elif defined( __clang__ ) && defined( __has_warning ) |
| 35 | #if __has_warning("-Wdeprecated-declarations") |
| 36 | #define BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS |
| 37 | #endif // __has_warning("-Wdeprecated-declarations") |
| 38 | #endif |
| 39 | #endif // defined( __GNUC__ ) && (defined( __GXX_EXPERIMENTAL_CXX0X__ ) || (__cplusplus >= 201103L)) |
| 40 | |
| 41 | #if defined( BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS ) |
| 42 | // Disable libstdc++ warnings about std::auto_ptr being deprecated in C++11 mode |
| 43 | #pragma GCC diagnostic push |
| 44 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 45 | #define BOOST_CORE_DETAIL_DISABLED_DEPRECATED_WARNINGS |
| 46 | #endif |
| 47 | |
| 48 | template<class T> T * get_pointer(std::auto_ptr<T> const& p) |
| 49 | { |
| 50 | return p.get(); |
| 51 | } |
| 52 | |
| 53 | #if defined( BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS ) |
| 54 | #pragma GCC diagnostic pop |
| 55 | #undef BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS |
| 56 | #endif |
| 57 | |
| 58 | #endif // !defined( BOOST_NO_AUTO_PTR ) |
| 59 | |
| 60 | #if !defined( BOOST_NO_CXX11_SMART_PTR ) |
| 61 | |
| 62 | template<class T> T * get_pointer( std::unique_ptr<T> const& p ) |
| 63 | { |
| 64 | return p.get(); |
| 65 | } |
| 66 | |
| 67 | template<class T> T * get_pointer( std::shared_ptr<T> const& p ) |
| 68 | { |
| 69 | return p.get(); |
| 70 | } |
| 71 | |
| 72 | #endif |
| 73 | |
| 74 | } // namespace boost |
| 75 | |
| 76 | #endif // GET_POINTER_DWA20021219_HPP |