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 // call_traits: defines typedefs for function usage
10 // (see libs/utility/call_traits.htm)
14 Fixed array specialization. (JM)
15 Added Borland specific fixes for reference types
16 (issue raised by Steve Cleary).
19 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
20 #define BOOST_DETAIL_CALL_TRAITS_HPP
22 #ifndef BOOST_CONFIG_HPP
23 #include <boost/config.hpp>
26 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
27 #include <boost/type_traits/arithmetic_traits.hpp>
29 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
30 #include <boost/type_traits/composite_traits.hpp>
37 template <typename T, bool small_>
40 typedef const T& param_type;
44 struct ct_imp2<T, true>
46 typedef const T param_type;
49 template <typename T, bool isp, bool b1>
52 typedef const T& param_type;
55 template <typename T, bool isp>
56 struct ct_imp<T, isp, true>
58 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
61 template <typename T, bool b1>
62 struct ct_imp<T, true, b1>
64 typedef T const param_type;
75 typedef const T& const_reference;
77 // C++ Builder workaround: we should be able to define a compile time
78 // constant and pass that as a single template parameter to ct_imp<T,bool>,
79 // however compiler bugs prevent this - instead pass three bool's to
80 // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
81 // of ct_imp to handle the logic. (JM)
82 typedef typename detail::ct_imp<
84 ::boost::is_pointer<T>::value,
85 ::boost::is_arithmetic<T>::value
86 >::param_type param_type;
90 struct call_traits<T&>
92 typedef T& value_type;
94 typedef const T& const_reference;
95 typedef T& param_type; // hh removed const
98 #if defined(__BORLANDC__) && (__BORLANDC__ <= 0x560)
99 // these are illegal specialisations; cv-qualifies applied to
100 // references have no effect according to [8.3.2p1],
101 // C++ Builder requires them though as it treats cv-qualified
102 // references as distinct types...
103 template <typename T>
104 struct call_traits<T&const>
106 typedef T& value_type;
107 typedef T& reference;
108 typedef const T& const_reference;
109 typedef T& param_type; // hh removed const
111 template <typename T>
112 struct call_traits<T&volatile>
114 typedef T& value_type;
115 typedef T& reference;
116 typedef const T& const_reference;
117 typedef T& param_type; // hh removed const
119 template <typename T>
120 struct call_traits<T&const volatile>
122 typedef T& value_type;
123 typedef T& reference;
124 typedef const T& const_reference;
125 typedef T& param_type; // hh removed const
129 template <typename T, std::size_t N>
130 struct call_traits<T [N]>
133 typedef T array_type[N];
135 // degrades array to pointer:
136 typedef const T* value_type;
137 typedef array_type& reference;
138 typedef const array_type& const_reference;
139 typedef const T* const param_type;
142 template <typename T, std::size_t N>
143 struct call_traits<const T [N]>
146 typedef const T array_type[N];
148 // degrades array to pointer:
149 typedef const T* value_type;
150 typedef array_type& reference;
151 typedef const array_type& const_reference;
152 typedef const T* const param_type;
158 #endif // BOOST_DETAIL_CALL_TRAITS_HPP