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_pointer.hpp>
33 template <typename T, bool small_>
36 typedef const T& param_type;
40 struct ct_imp2<T, true>
42 typedef const T param_type;
45 template <typename T, bool isp, bool b1>
48 typedef const T& param_type;
51 template <typename T, bool isp>
52 struct ct_imp<T, isp, true>
54 typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
57 template <typename T, bool b1>
58 struct ct_imp<T, true, b1>
60 typedef T const param_type;
71 typedef const T& const_reference;
73 // C++ Builder workaround: we should be able to define a compile time
74 // constant and pass that as a single template parameter to ct_imp<T,bool>,
75 // however compiler bugs prevent this - instead pass three bool's to
76 // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
77 // of ct_imp to handle the logic. (JM)
78 typedef typename detail::ct_imp<
80 ::boost::is_pointer<T>::value,
81 ::boost::is_arithmetic<T>::value
82 >::param_type param_type;
86 struct call_traits<T&>
88 typedef T& value_type;
90 typedef const T& const_reference;
91 typedef T& param_type; // hh removed const
94 #if defined(__BORLANDC__) && (__BORLANDC__ <= 0x560)
95 // these are illegal specialisations; cv-qualifies applied to
96 // references have no effect according to [8.3.2p1],
97 // C++ Builder requires them though as it treats cv-qualified
98 // references as distinct types...
100 struct call_traits<T&const>
102 typedef T& value_type;
103 typedef T& reference;
104 typedef const T& const_reference;
105 typedef T& param_type; // hh removed const
107 template <typename T>
108 struct call_traits<T&volatile>
110 typedef T& value_type;
111 typedef T& reference;
112 typedef const T& const_reference;
113 typedef T& param_type; // hh removed const
115 template <typename T>
116 struct call_traits<T&const volatile>
118 typedef T& value_type;
119 typedef T& reference;
120 typedef const T& const_reference;
121 typedef T& param_type; // hh removed const
124 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
125 template <typename T, std::size_t N>
126 struct call_traits<T [N]>
129 typedef T array_type[N];
131 // degrades array to pointer:
132 typedef const T* value_type;
133 typedef array_type& reference;
134 typedef const array_type& const_reference;
135 typedef const T* const param_type;
138 template <typename T, std::size_t N>
139 struct call_traits<const T [N]>
142 typedef const T array_type[N];
144 // degrades array to pointer:
145 typedef const T* value_type;
146 typedef array_type& reference;
147 typedef const array_type& const_reference;
148 typedef const T* const param_type;
154 #endif // BOOST_DETAIL_CALL_TRAITS_HPP