Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/detail/call_traits.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. | |
2 // Use, modification and distribution are subject to the Boost Software License, | |
3 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
4 // http://www.boost.org/LICENSE_1_0.txt). | |
5 // | |
6 // See http://www.boost.org/libs/utility for most recent version including documentation. | |
7 | |
8 // call_traits: defines typedefs for function usage | |
9 // (see libs/utility/call_traits.htm) | |
10 | |
11 /* Release notes: | |
12 23rd July 2000: | |
13 Fixed array specialization. (JM) | |
14 Added Borland specific fixes for reference types | |
15 (issue raised by Steve Cleary). | |
16 */ | |
17 | |
18 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP | |
19 #define BOOST_DETAIL_CALL_TRAITS_HPP | |
20 | |
21 #ifndef BOOST_CONFIG_HPP | |
22 #include <boost/config.hpp> | |
23 #endif | |
24 #include <cstddef> | |
25 | |
26 #include <boost/type_traits/is_arithmetic.hpp> | |
27 #include <boost/type_traits/is_enum.hpp> | |
28 #include <boost/type_traits/is_pointer.hpp> | |
29 #include <boost/detail/workaround.hpp> | |
30 | |
31 namespace boost{ | |
32 | |
33 namespace detail{ | |
34 | |
35 template <typename T, bool small_> | |
36 struct ct_imp2 | |
37 { | |
38 typedef const T& param_type; | |
39 }; | |
40 | |
41 template <typename T> | |
42 struct ct_imp2<T, true> | |
43 { | |
44 typedef const T param_type; | |
45 }; | |
46 | |
47 template <typename T, bool isp, bool b1, bool b2> | |
48 struct ct_imp | |
49 { | |
50 typedef const T& param_type; | |
51 }; | |
52 | |
53 template <typename T, bool isp, bool b2> | |
54 struct ct_imp<T, isp, true, b2> | |
55 { | |
56 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type; | |
57 }; | |
58 | |
59 template <typename T, bool isp, bool b1> | |
60 struct ct_imp<T, isp, b1, true> | |
61 { | |
62 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type; | |
63 }; | |
64 | |
65 template <typename T, bool b1, bool b2> | |
66 struct ct_imp<T, true, b1, b2> | |
67 { | |
68 typedef const T param_type; | |
69 }; | |
70 | |
71 } | |
72 | |
73 template <typename T> | |
74 struct call_traits | |
75 { | |
76 public: | |
77 typedef T value_type; | |
78 typedef T& reference; | |
79 typedef const T& const_reference; | |
80 // | |
81 // C++ Builder workaround: we should be able to define a compile time | |
82 // constant and pass that as a single template parameter to ct_imp<T,bool>, | |
83 // however compiler bugs prevent this - instead pass three bool's to | |
84 // ct_imp<T,bool,bool,bool> and add an extra partial specialisation | |
85 // of ct_imp to handle the logic. (JM) | |
86 typedef typename boost::detail::ct_imp< | |
87 T, | |
88 ::boost::is_pointer<T>::value, | |
89 ::boost::is_arithmetic<T>::value, | |
90 ::boost::is_enum<T>::value | |
91 >::param_type param_type; | |
92 }; | |
93 | |
94 template <typename T> | |
95 struct call_traits<T&> | |
96 { | |
97 typedef T& value_type; | |
98 typedef T& reference; | |
99 typedef const T& const_reference; | |
100 typedef T& param_type; // hh removed const | |
101 }; | |
102 | |
103 #if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 ) | |
104 // these are illegal specialisations; cv-qualifies applied to | |
105 // references have no effect according to [8.3.2p1], | |
106 // C++ Builder requires them though as it treats cv-qualified | |
107 // references as distinct types... | |
108 template <typename T> | |
109 struct call_traits<T&const> | |
110 { | |
111 typedef T& value_type; | |
112 typedef T& reference; | |
113 typedef const T& const_reference; | |
114 typedef T& param_type; // hh removed const | |
115 }; | |
116 template <typename T> | |
117 struct call_traits<T&volatile> | |
118 { | |
119 typedef T& value_type; | |
120 typedef T& reference; | |
121 typedef const T& const_reference; | |
122 typedef T& param_type; // hh removed const | |
123 }; | |
124 template <typename T> | |
125 struct call_traits<T&const volatile> | |
126 { | |
127 typedef T& value_type; | |
128 typedef T& reference; | |
129 typedef const T& const_reference; | |
130 typedef T& param_type; // hh removed const | |
131 }; | |
132 | |
133 template <typename T> | |
134 struct call_traits< T * > | |
135 { | |
136 typedef T * value_type; | |
137 typedef T * & reference; | |
138 typedef T * const & const_reference; | |
139 typedef T * const param_type; // hh removed const | |
140 }; | |
141 #endif | |
142 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) | |
143 template <typename T, std::size_t N> | |
144 struct call_traits<T [N]> | |
145 { | |
146 private: | |
147 typedef T array_type[N]; | |
148 public: | |
149 // degrades array to pointer: | |
150 typedef const T* value_type; | |
151 typedef array_type& reference; | |
152 typedef const array_type& const_reference; | |
153 typedef const T* const param_type; | |
154 }; | |
155 | |
156 template <typename T, std::size_t N> | |
157 struct call_traits<const T [N]> | |
158 { | |
159 private: | |
160 typedef const T array_type[N]; | |
161 public: | |
162 // degrades array to pointer: | |
163 typedef const T* value_type; | |
164 typedef array_type& reference; | |
165 typedef const array_type& const_reference; | |
166 typedef const T* const param_type; | |
167 }; | |
168 #endif | |
169 | |
170 } | |
171 | |
172 #endif // BOOST_DETAIL_CALL_TRAITS_HPP |