]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/call_traits.hpp
Boost 1.31.0
[lyx.git] / boost / boost / detail / call_traits.hpp
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_pointer.hpp>
28
29 namespace boost{
30
31 namespace detail{
32
33 template <typename T, bool small_>
34 struct ct_imp2
35 {
36    typedef const T& param_type;
37 };
38
39 template <typename T>
40 struct ct_imp2<T, true>
41 {
42    typedef const T param_type;
43 };
44
45 template <typename T, bool isp, bool b1>
46 struct ct_imp
47 {
48    typedef const T& param_type;
49 };
50
51 template <typename T, bool isp>
52 struct ct_imp<T, isp, true>
53 {
54    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
55 };
56
57 template <typename T, bool b1>
58 struct ct_imp<T, true, b1>
59 {
60    typedef T const param_type;
61 };
62
63 }
64
65 template <typename T>
66 struct call_traits
67 {
68 public:
69    typedef T value_type;
70    typedef T& reference;
71    typedef const T& const_reference;
72    //
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<
79       T,
80       ::boost::is_pointer<T>::value,
81       ::boost::is_arithmetic<T>::value
82    >::param_type param_type;
83 };
84
85 template <typename T>
86 struct call_traits<T&>
87 {
88    typedef T& value_type;
89    typedef T& reference;
90    typedef const T& const_reference;
91    typedef T& param_type;  // hh removed const
92 };
93
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...
99 template <typename T>
100 struct call_traits<T&const>
101 {
102    typedef T& value_type;
103    typedef T& reference;
104    typedef const T& const_reference;
105    typedef T& param_type;  // hh removed const
106 };
107 template <typename T>
108 struct call_traits<T&volatile>
109 {
110    typedef T& value_type;
111    typedef T& reference;
112    typedef const T& const_reference;
113    typedef T& param_type;  // hh removed const
114 };
115 template <typename T>
116 struct call_traits<T&const volatile>
117 {
118    typedef T& value_type;
119    typedef T& reference;
120    typedef const T& const_reference;
121    typedef T& param_type;  // hh removed const
122 };
123 #endif
124 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
125 template <typename T, std::size_t N>
126 struct call_traits<T [N]>
127 {
128 private:
129    typedef T array_type[N];
130 public:
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;
136 };
137
138 template <typename T, std::size_t N>
139 struct call_traits<const T [N]>
140 {
141 private:
142    typedef const T array_type[N];
143 public:
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;
149 };
150 #endif
151
152 }
153
154 #endif // BOOST_DETAIL_CALL_TRAITS_HPP