#ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED #define BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED // // Copyright 2015 Peter Dimov // // 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 // #include #include #include #include #include #include #include namespace boost { namespace type_traits_detail { template struct composite_pointer_type; // same type template struct composite_pointer_type { typedef T* type; }; // nullptr_t #if !defined( BOOST_NO_CXX11_NULLPTR ) #if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) ) template struct composite_pointer_type { typedef T* type; }; template struct composite_pointer_type { typedef T* type; }; template<> struct composite_pointer_type { typedef decltype(nullptr) type; }; #else template struct composite_pointer_type { typedef T* type; }; template struct composite_pointer_type { typedef T* type; }; template<> struct composite_pointer_type { typedef std::nullptr_t type; }; #endif #endif // !defined( BOOST_NO_CXX11_NULLPTR ) namespace detail { template struct has_common_pointee { private: typedef typename boost::remove_cv::type T2; typedef typename boost::remove_cv::type U2; public: BOOST_STATIC_CONSTANT( bool, value = (boost::is_same::value) || boost::is_void::value || boost::is_void::value || (boost::is_base_of::value) || (boost::is_base_of::value) ); }; template struct common_pointee { private: typedef typename boost::remove_cv::type T2; typedef typename boost::remove_cv::type U2; public: typedef typename boost::conditional< boost::is_same::value || boost::is_void::value || boost::is_base_of::value, typename boost::copy_cv::type, typename boost::copy_cv::type >::type type; }; template struct composite_pointer_impl { private: typedef typename boost::remove_cv::type T2; typedef typename boost::remove_cv::type U2; public: typedef typename boost::copy_cv::type const, T>::type, U>::type type; }; //Old compilers like MSVC-7.1 have problems using boost::conditional in //composite_pointer_type. Partially specializing on has_common_pointee::value //seems to make their life easier template::value > struct composite_pointer_type_dispatch : common_pointee {}; template struct composite_pointer_type_dispatch : composite_pointer_impl {}; } // detail template struct composite_pointer_type { typedef typename detail::composite_pointer_type_dispatch::type* type; }; } // namespace type_traits_detail } // namespace boost #endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED