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).
6 // See http://www.boost.org/libs/utility for most recent version including documentation.
8 // call_traits: defines typedefs for function usage
9 // (see libs/utility/call_traits.htm)
13 Fixed array specialization. (JM)
14 Added Borland specific fixes for reference types
15 (issue raised by Steve Cleary).
18 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
19 #define BOOST_DETAIL_CALL_TRAITS_HPP
21 #ifndef BOOST_CONFIG_HPP
22 #include <boost/config.hpp>
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>
35 template <typename T, bool small_>
38 typedef const T& param_type;
42 struct ct_imp2<T, true>
44 typedef const T param_type;
47 template <typename T, bool isp, bool b1, bool b2>
50 typedef const T& param_type;
53 template <typename T, bool isp, bool b2>
54 struct ct_imp<T, isp, true, b2>
56 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
59 template <typename T, bool isp, bool b1>
60 struct ct_imp<T, isp, b1, true>
62 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
65 template <typename T, bool b1, bool b2>
66 struct ct_imp<T, true, b1, b2>
68 typedef const T param_type;
79 typedef const T& const_reference;
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<
88 ::boost::is_pointer<T>::value,
89 ::boost::is_arithmetic<T>::value,
90 ::boost::is_enum<T>::value
91 >::param_type param_type;
95 struct call_traits<T&>
97 typedef T& value_type;
99 typedef const T& const_reference;
100 typedef T& param_type; // hh removed const
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>
111 typedef T& value_type;
112 typedef T& reference;
113 typedef const T& const_reference;
114 typedef T& param_type; // hh removed const
116 template <typename T>
117 struct call_traits<T&volatile>
119 typedef T& value_type;
120 typedef T& reference;
121 typedef const T& const_reference;
122 typedef T& param_type; // hh removed const
124 template <typename T>
125 struct call_traits<T&const volatile>
127 typedef T& value_type;
128 typedef T& reference;
129 typedef const T& const_reference;
130 typedef T& param_type; // hh removed const
133 template <typename T>
134 struct call_traits< T * >
136 typedef T * value_type;
137 typedef T * & reference;
138 typedef T * const & const_reference;
139 typedef T * const param_type; // hh removed const
142 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
143 template <typename T, std::size_t N>
144 struct call_traits<T [N]>
147 typedef T array_type[N];
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;
156 template <typename T, std::size_t N>
157 struct call_traits<const T [N]>
160 typedef const T array_type[N];
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;
172 #endif // BOOST_DETAIL_CALL_TRAITS_HPP