1 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
2 // Permission to copy, use, modify, sell and
3 // distribute this software is granted provided this copyright notice appears
4 // in all copies. This software is provided "as is" without express or implied
5 // warranty, and with no claim as to its suitability for any purpose.
7 // See http://www.boost.org for most recent version including documentation.
9 // defines traits classes for transforming one type to another:
10 // remove_reference, add_reference, remove_bounds, remove_pointer.
14 // Added void specialisations to add_reference.
16 #ifndef BOOST_TRANSFORM_TRAITS_HPP
17 #define BOOST_TRANSFORM_TRAITS_HPP
19 #ifndef BOOST_ICE_TYPE_TRAITS_HPP
20 #include <boost/type_traits/ice.hpp>
22 #ifndef BOOST_FWD_TYPE_TRAITS_HPP
23 #include <boost/type_traits/fwd.hpp>
25 #if !defined(BOOST_COMPOSITE_TYPE_TRAITS_HPP) && defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
26 #include <boost/type_traits/composite_traits.hpp>
31 /**********************************************
35 **********************************************/
37 struct remove_reference
39 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
41 struct remove_reference<T&>
44 #if defined(__BORLANDC__) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
45 // these are illegal specialisations; cv-qualifies applied to
46 // references have no effect according to [8.3.2p1],
47 // C++ Builder requires them though as it treats cv-qualified
48 // references as distinct types...
50 struct remove_reference<T&const>
53 struct remove_reference<T&volatile>
56 struct remove_reference<T&const volatile>
60 /**********************************************
64 **********************************************/
65 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
70 struct add_reference<T&>
72 #elif defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_MEMBER_TEMPLATES)
76 struct reference_adder
86 struct reference_adder<true>
101 typedef typename detail::reference_adder< ::boost::is_reference<T>::value>::template rebind<T> binder;
103 typedef typename binder::type type;
107 template <typename T>
109 { typedef T& type; };
113 // these full specialisations are always required:
114 template <> struct add_reference<void>{ typedef void type; };
115 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
116 template <> struct add_reference<const volatile void>{ typedef const volatile void type; };
117 template <> struct add_reference<const void>{ typedef const void type; };
118 template <> struct add_reference<volatile void>{ typedef volatile void type; };
122 /**********************************************
126 **********************************************/
127 template <typename T>
130 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
131 template <typename T, std::size_t N>
132 struct remove_bounds<T[N]>
134 template <typename T, std::size_t N>
135 struct remove_bounds<const T[N]>
136 { typedef const T type; };
137 template <typename T, std::size_t N>
138 struct remove_bounds<volatile T[N]>
139 { typedef volatile T type; };
140 template <typename T, std::size_t N>
141 struct remove_bounds<const volatile T[N]>
142 { typedef const volatile T type; };
145 /**********************************************
149 **********************************************/
150 template <typename T>
151 struct remove_pointer
153 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
154 template <typename T>
155 struct remove_pointer<T*>
157 template <typename T>
158 struct remove_pointer<T*const>
160 template <typename T>
161 struct remove_pointer<T*volatile>
163 template <typename T>
164 struct remove_pointer<T*const volatile>
168 /**********************************************
172 **********************************************/
173 template <typename T>
177 typedef typename remove_reference<T>::type no_ref_type;
178 typedef typename remove_bounds<no_ref_type>::type no_b_type;
180 typedef no_b_type* type;
185 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
187 // if there is no partial specialisation support
188 // include a bunch of full specialisations as a workaround:
190 #include <boost/type_traits/transform_traits_spec.hpp>
192 #define BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(x)
195 #endif // BOOST_TRANSFORM_TRAITS_HPP