]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/transform_traits.hpp
6cc0536e4e7a4b8778057f0cbe6670703137671d
[lyx.git] / boost / boost / type_traits / transform_traits.hpp
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.
6 //
7 //  See http://www.boost.org for most recent version including documentation.
8 //
9 //  defines traits classes for transforming one type to another:
10 //  remove_reference, add_reference, remove_bounds, remove_pointer.
11 //
12 // Revision History:
13 // 21st March 2001
14 //    Added void specialisations to add_reference.
15
16 #ifndef BOOST_TRANSFORM_TRAITS_HPP
17 #define BOOST_TRANSFORM_TRAITS_HPP
18
19 #ifndef BOOST_ICE_TYPE_TRAITS_HPP
20 #include <boost/type_traits/ice.hpp>
21 #endif
22 #ifndef BOOST_FWD_TYPE_TRAITS_HPP
23 #include <boost/type_traits/fwd.hpp>
24 #endif
25 #if !defined(BOOST_COMPOSITE_TYPE_TRAITS_HPP) && defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
26 #include <boost/type_traits/composite_traits.hpp>
27 #endif
28
29 namespace boost{
30
31 /**********************************************
32  *
33  * remove_reference
34  *
35  **********************************************/
36 template <typename T>
37 struct remove_reference
38 { typedef T type; };
39 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
40 template <typename T>
41 struct remove_reference<T&>
42 { typedef T type; };
43 #endif
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...
49 template <typename T>
50 struct remove_reference<T&const>
51 { typedef T type; };
52 template <typename T>
53 struct remove_reference<T&volatile>
54 { typedef T type; };
55 template <typename T>
56 struct remove_reference<T&const volatile>
57 { typedef T type; };
58 #endif
59
60 /**********************************************
61  *
62  * add_reference
63  *
64  **********************************************/
65 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
66 template <typename T>
67 struct add_reference
68 { typedef T& type; };
69 template <typename T>
70 struct add_reference<T&>
71 { typedef T& type; };
72 #elif defined(BOOST_MSVC6_MEMBER_TEMPLATES)
73 namespace detail{
74
75 template <bool x>
76 struct reference_adder
77 {
78    template <class T>
79    struct rebind
80    {
81       typedef T& type;
82    };
83 };
84
85 template <>
86 struct reference_adder<true>
87 {
88    template <class T>
89    struct rebind
90    {
91       typedef T type;
92    };
93 };
94
95 } // namespace detail
96
97 template <typename T>
98 struct add_reference
99 {
100 private:
101    typedef typename detail::reference_adder< ::boost::is_reference<T>::value>::template rebind<T> binder;
102 public:
103    typedef typename binder::type type;
104 };
105
106 #else
107 template <typename T>
108 struct add_reference
109 { typedef T& type; };
110 #endif
111
112 //
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; };
119 #endif
120
121
122 /**********************************************
123  *
124  * remove_bounds
125  *
126  **********************************************/
127 template <typename T>
128 struct remove_bounds
129 { typedef T type; };
130 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
131 template <typename T, std::size_t N>
132 struct remove_bounds<T[N]>
133 { typedef T type; };
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; };
143 #endif
144
145 /**********************************************
146  *
147  * remove_pointer
148  *
149  **********************************************/
150 template <typename T>
151 struct remove_pointer
152 { typedef T type; };
153 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
154 template <typename T>
155 struct remove_pointer<T*>
156 { typedef T type; };
157 template <typename T>
158 struct remove_pointer<T*const>
159 { typedef T type; };
160 template <typename T>
161 struct remove_pointer<T*volatile>
162 { typedef T type; };
163 template <typename T>
164 struct remove_pointer<T*const volatile>
165 { typedef T type; };
166 #endif
167
168 /**********************************************
169  *
170  * add_pointer
171  *
172  **********************************************/
173 template <typename T>
174 struct add_pointer
175 {
176 private:
177    typedef typename remove_reference<T>::type no_ref_type;
178 public:
179    typedef no_ref_type* type;
180 };
181
182 } // namespace boost
183
184 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
185 //
186 // if there is no partial specialisation support
187 // include a bunch of full specialisations as a workaround:
188 //
189 #include <boost/type_traits/transform_traits_spec.hpp>
190 #else
191 #define BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(x)
192 #endif
193
194 #endif // BOOST_TRANSFORM_TRAITS_HPP
195  
196
197
198
199