1 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
\r
2 // Use, modification and distribution are subject to the Boost Software License,
\r
3 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
\r
4 // http://www.boost.org/LICENSE_1_0.txt).
\r
6 // See http://www.boost.org/libs/utility for most recent version including documentation.
\r
8 // call_traits: defines typedefs for function usage
\r
9 // (see libs/utility/call_traits.htm)
\r
13 Fixed array specialization. (JM)
\r
14 Added Borland specific fixes for reference types
\r
15 (issue raised by Steve Cleary).
\r
18 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
\r
19 #define BOOST_DETAIL_CALL_TRAITS_HPP
\r
21 #ifndef BOOST_CONFIG_HPP
\r
22 #include <boost/config.hpp>
\r
26 #include <boost/type_traits/is_arithmetic.hpp>
\r
27 #include <boost/type_traits/is_pointer.hpp>
\r
28 #include <boost/detail/workaround.hpp>
\r
34 template <typename T, bool small_>
\r
37 typedef const T& param_type;
\r
40 template <typename T>
\r
41 struct ct_imp2<T, true>
\r
43 typedef const T param_type;
\r
46 template <typename T, bool isp, bool b1>
\r
49 typedef const T& param_type;
\r
52 template <typename T, bool isp>
\r
53 struct ct_imp<T, isp, true>
\r
55 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
\r
58 template <typename T, bool b1>
\r
59 struct ct_imp<T, true, b1>
\r
61 typedef const T param_type;
\r
66 template <typename T>
\r
70 typedef T value_type;
\r
71 typedef T& reference;
\r
72 typedef const T& const_reference;
\r
74 // C++ Builder workaround: we should be able to define a compile time
\r
75 // constant and pass that as a single template parameter to ct_imp<T,bool>,
\r
76 // however compiler bugs prevent this - instead pass three bool's to
\r
77 // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
\r
78 // of ct_imp to handle the logic. (JM)
\r
79 typedef typename boost::detail::ct_imp<
\r
81 ::boost::is_pointer<T>::value,
\r
82 ::boost::is_arithmetic<T>::value
\r
83 >::param_type param_type;
\r
86 template <typename T>
\r
87 struct call_traits<T&>
\r
89 typedef T& value_type;
\r
90 typedef T& reference;
\r
91 typedef const T& const_reference;
\r
92 typedef T& param_type; // hh removed const
\r
95 #if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
\r
96 // these are illegal specialisations; cv-qualifies applied to
\r
97 // references have no effect according to [8.3.2p1],
\r
98 // C++ Builder requires them though as it treats cv-qualified
\r
99 // references as distinct types...
\r
100 template <typename T>
\r
101 struct call_traits<T&const>
\r
103 typedef T& value_type;
\r
104 typedef T& reference;
\r
105 typedef const T& const_reference;
\r
106 typedef T& param_type; // hh removed const
\r
108 template <typename T>
\r
109 struct call_traits<T&volatile>
\r
111 typedef T& value_type;
\r
112 typedef T& reference;
\r
113 typedef const T& const_reference;
\r
114 typedef T& param_type; // hh removed const
\r
116 template <typename T>
\r
117 struct call_traits<T&const volatile>
\r
119 typedef T& value_type;
\r
120 typedef T& reference;
\r
121 typedef const T& const_reference;
\r
122 typedef T& param_type; // hh removed const
\r
125 template <typename T>
\r
126 struct call_traits< T * >
\r
128 typedef T * value_type;
\r
129 typedef T * & reference;
\r
130 typedef T * const & const_reference;
\r
131 typedef T * const param_type; // hh removed const
\r
134 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
\r
135 template <typename T, std::size_t N>
\r
136 struct call_traits<T [N]>
\r
139 typedef T array_type[N];
\r
141 // degrades array to pointer:
\r
142 typedef const T* value_type;
\r
143 typedef array_type& reference;
\r
144 typedef const array_type& const_reference;
\r
145 typedef const T* const param_type;
\r
148 template <typename T, std::size_t N>
\r
149 struct call_traits<const T [N]>
\r
152 typedef const T array_type[N];
\r
154 // degrades array to pointer:
\r
155 typedef const T* value_type;
\r
156 typedef array_type& reference;
\r
157 typedef const array_type& const_reference;
\r
158 typedef const T* const param_type;
\r
164 #endif // BOOST_DETAIL_CALL_TRAITS_HPP
\r