File indexing completed on 2025-01-30 09:46:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MOVE_DETAIL_POINTER_ELEMENT_HPP
0012 #define BOOST_MOVE_DETAIL_POINTER_ELEMENT_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
0023 #include <boost/move/detail/workaround.hpp>
0024 #endif
0025
0026 namespace boost {
0027 namespace movelib {
0028 namespace detail{
0029
0030
0031
0032
0033
0034 template <typename T> struct first_param
0035 { typedef void type; };
0036
0037 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0038
0039 template <template <typename, typename...> class TemplateClass, typename T, typename... Args>
0040 struct first_param< TemplateClass<T, Args...> >
0041 {
0042 typedef T type;
0043 };
0044
0045 #else
0046
0047 template < template
0048 <class
0049 > class TemplateClass, class T
0050 >
0051 struct first_param
0052 < TemplateClass<T> >
0053 { typedef T type; };
0054
0055 template < template
0056 <class,class
0057 > class TemplateClass, class T
0058 , class P0>
0059 struct first_param
0060 < TemplateClass<T, P0> >
0061 { typedef T type; };
0062
0063 template < template
0064 <class,class,class
0065 > class TemplateClass, class T
0066 , class P0, class P1>
0067 struct first_param
0068 < TemplateClass<T, P0, P1> >
0069 { typedef T type; };
0070
0071 template < template
0072 <class,class,class,class
0073 > class TemplateClass, class T
0074 , class P0, class P1, class P2>
0075 struct first_param
0076 < TemplateClass<T, P0, P1, P2> >
0077 { typedef T type; };
0078
0079 template < template
0080 <class,class,class,class,class
0081 > class TemplateClass, class T
0082 , class P0, class P1, class P2, class P3>
0083 struct first_param
0084 < TemplateClass<T, P0, P1, P2, P3> >
0085 { typedef T type; };
0086
0087 template < template
0088 <class,class,class,class,class,class
0089 > class TemplateClass, class T
0090 , class P0, class P1, class P2, class P3, class P4>
0091 struct first_param
0092 < TemplateClass<T, P0, P1, P2, P3, P4> >
0093 { typedef T type; };
0094
0095 template < template
0096 <class,class,class,class,class,class,class
0097 > class TemplateClass, class T
0098 , class P0, class P1, class P2, class P3, class P4, class P5>
0099 struct first_param
0100 < TemplateClass<T, P0, P1, P2, P3, P4, P5> >
0101 { typedef T type; };
0102
0103 template < template
0104 <class,class,class,class,class,class,class,class
0105 > class TemplateClass, class T
0106 , class P0, class P1, class P2, class P3, class P4, class P5, class P6>
0107 struct first_param
0108 < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6> >
0109 { typedef T type; };
0110
0111 template < template
0112 <class,class,class,class,class,class,class,class,class
0113 > class TemplateClass, class T
0114 , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
0115 struct first_param
0116 < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7> >
0117 { typedef T type; };
0118
0119 template < template
0120 <class,class,class,class,class,class,class,class,class,class
0121 > class TemplateClass, class T
0122 , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
0123 struct first_param
0124 < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7, P8> >
0125 { typedef T type; };
0126
0127 #endif
0128
0129 template <typename T>
0130 struct has_internal_pointer_element
0131 {
0132 template <typename X>
0133 static char test(int, typename X::element_type*);
0134
0135 template <typename X>
0136 static int test(...);
0137
0138 static const bool value = (1 == sizeof(test<T>(0, 0)));
0139 };
0140
0141 template<class Ptr, bool = has_internal_pointer_element<Ptr>::value>
0142 struct pointer_element_impl
0143 {
0144 typedef typename Ptr::element_type type;
0145 };
0146
0147 template<class Ptr>
0148 struct pointer_element_impl<Ptr, false>
0149 {
0150 typedef typename boost::movelib::detail::first_param<Ptr>::type type;
0151 };
0152
0153 }
0154
0155 template <typename Ptr>
0156 struct pointer_element
0157 {
0158 typedef typename ::boost::movelib::detail::pointer_element_impl<Ptr>::type type;
0159 };
0160
0161 template <typename T>
0162 struct pointer_element<T*>
0163 { typedef T type; };
0164
0165 }
0166 }
0167
0168 #endif