]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/call_traits.hpp
add __alpha__ as supported cpu
[lyx.git] / boost / boost / detail / call_traits.hpp
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.
6
7 //  See http://www.boost.org for most recent version including documentation.
8
9 // call_traits: defines typedefs for function usage
10 // (see libs/utility/call_traits.htm)
11
12 /* Release notes:
13    23rd July 2000:
14       Fixed array specialization. (JM)
15       Added Borland specific fixes for reference types
16       (issue raised by Steve Cleary).
17 */
18
19 #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
20 #define BOOST_DETAIL_CALL_TRAITS_HPP
21
22 #ifndef BOOST_CONFIG_HPP
23 #include <boost/config.hpp>
24 #endif
25
26 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
27 #include <boost/type_traits/arithmetic_traits.hpp>
28 #endif
29 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
30 #include <boost/type_traits/composite_traits.hpp>
31 #endif
32
33 namespace boost{
34
35 namespace detail{
36
37 template <typename T, bool small_>
38 struct ct_imp2
39 {
40    typedef const T& param_type;
41 };
42
43 template <typename T>
44 struct ct_imp2<T, true>
45 {
46    typedef const T param_type;
47 };
48
49 template <typename T, bool isp, bool b1>
50 struct ct_imp
51 {
52    typedef const T& param_type;
53 };
54
55 template <typename T, bool isp>
56 struct ct_imp<T, isp, true>
57 {
58    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
59 };
60
61 template <typename T, bool b1>
62 struct ct_imp<T, true, b1>
63 {
64    typedef T const param_type;
65 };
66
67 }
68
69 template <typename T>
70 struct call_traits
71 {
72 public:
73    typedef T value_type;
74    typedef T& reference;
75    typedef const T& const_reference;
76    //
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<
83       T,
84       ::boost::is_pointer<T>::value,
85       ::boost::is_arithmetic<T>::value
86    >::param_type param_type;
87 };
88
89 template <typename T>
90 struct call_traits<T&>
91 {
92    typedef T& value_type;
93    typedef T& reference;
94    typedef const T& const_reference;
95    typedef T& param_type;  // hh removed const
96 };
97
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>
105 {
106    typedef T& value_type;
107    typedef T& reference;
108    typedef const T& const_reference;
109    typedef T& param_type;  // hh removed const
110 };
111 template <typename T>
112 struct call_traits<T&volatile>
113 {
114    typedef T& value_type;
115    typedef T& reference;
116    typedef const T& const_reference;
117    typedef T& param_type;  // hh removed const
118 };
119 template <typename T>
120 struct call_traits<T&const volatile>
121 {
122    typedef T& value_type;
123    typedef T& reference;
124    typedef const T& const_reference;
125    typedef T& param_type;  // hh removed const
126 };
127 #endif
128 #ifndef __SUNPRO_CC
129 template <typename T, std::size_t N>
130 struct call_traits<T [N]>
131 {
132 private:
133    typedef T array_type[N];
134 public:
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;
140 };
141
142 template <typename T, std::size_t N>
143 struct call_traits<const T [N]>
144 {
145 private:
146    typedef const T array_type[N];
147 public:
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;
153 };
154 #endif
155
156 }
157
158 #endif // BOOST_DETAIL_CALL_TRAITS_HPP