1 #ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED
2 #define BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED
5 // Copyright 2015 Peter Dimov
7 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
12 #include <boost/type_traits/detail/composite_pointer_type.hpp>
13 #include <boost/type_traits/remove_pointer.hpp>
14 #include <boost/type_traits/is_base_of.hpp>
15 #include <boost/type_traits/conditional.hpp>
16 #include <boost/config.hpp>
22 namespace type_traits_detail
25 template<class T, class U> struct composite_member_pointer_type;
29 #if !defined( BOOST_NO_CXX11_NULLPTR )
31 #if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) )
33 template<class C, class T> struct composite_member_pointer_type<T C::*, decltype(nullptr)>
38 template<class C, class T> struct composite_member_pointer_type<decltype(nullptr), T C::*>
43 template<> struct composite_member_pointer_type<decltype(nullptr), decltype(nullptr)>
45 typedef decltype(nullptr) type;
50 template<class C, class T> struct composite_member_pointer_type<T C::*, std::nullptr_t>
55 template<class C, class T> struct composite_member_pointer_type<std::nullptr_t, T C::*>
60 template<> struct composite_member_pointer_type<std::nullptr_t, std::nullptr_t>
62 typedef std::nullptr_t type;
67 #endif // !defined( BOOST_NO_CXX11_NULLPTR )
69 template<class C1, class C2> struct common_member_class;
71 template<class C> struct common_member_class<C, C>
76 template<class C1, class C2> struct common_member_class
78 typedef typename boost::conditional<
80 boost::is_base_of<C1, C2>::value,
82 typename boost::conditional<boost::is_base_of<C2, C1>::value, C1, void>::type
87 //This indirection avoids compilation errors on some older
88 //compilers like MSVC 7.1
89 template<class CT, class CB>
90 struct common_member_class_pointer_to_member
92 typedef CT CB::* type;
95 template<class C1, class T1, class C2, class T2> struct composite_member_pointer_type<T1 C1::*, T2 C2::*>
99 typedef typename composite_pointer_type<T1*, T2*>::type CPT;
100 typedef typename boost::remove_pointer<CPT>::type CT;
102 typedef typename common_member_class<C1, C2>::type CB;
106 typedef typename common_member_class_pointer_to_member<CT, CB>::type type;
109 } // namespace type_traits_detail
113 #endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED