Line data Source code
1 : /* Copyright 2003-2015 Joaquin M Lopez Munoz. 2 : * Distributed under the Boost Software License, Version 1.0. 3 : * (See accompanying file LICENSE_1_0.txt or copy at 4 : * http://www.boost.org/LICENSE_1_0.txt) 5 : * 6 : * See http://www.boost.org/libs/multi_index for library home page. 7 : */ 8 : 9 : #ifndef BOOST_MULTI_INDEX_DETAIL_RAW_PTR_HPP 10 : #define BOOST_MULTI_INDEX_DETAIL_RAW_PTR_HPP 11 : 12 : #if defined(_MSC_VER) 13 : #pragma once 14 : #endif 15 : 16 : #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ 17 : #include <boost/mpl/bool.hpp> 18 : #include <boost/type_traits/is_same.hpp> 19 : 20 : namespace boost{ 21 : 22 : namespace multi_index{ 23 : 24 : namespace detail{ 25 : 26 : /* gets the underlying pointer of a pointer-like value */ 27 : 28 : template<typename RawPointer> 29 0 : inline RawPointer raw_ptr(RawPointer const& p,mpl::true_) 30 : { 31 : return p; 32 : } 33 : 34 : template<typename RawPointer,typename Pointer> 35 : inline RawPointer raw_ptr(Pointer const& p,mpl::false_) 36 : { 37 : return p==Pointer(0)?0:&*p; 38 : } 39 : 40 : template<typename RawPointer,typename Pointer> 41 0 : inline RawPointer raw_ptr(Pointer const& p) 42 : { 43 0 : return raw_ptr<RawPointer>(p,is_same<RawPointer,Pointer>()); 44 : } 45 : 46 : } /* namespace multi_index::detail */ 47 : 48 : } /* namespace multi_index */ 49 : 50 : } /* namespace boost */ 51 : 52 : #endif