]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/detail/ob_call_traits.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
eaf9cbeb076b862d553636c6ff8273c7598213f2
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / detail / ob_call_traits.hpp
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
5 //\r
6 //  See http://www.boost.org/libs/utility for most recent version including documentation.\r
7 //\r
8 //  Crippled version for crippled compilers:\r
9 //  see libs/utility/call_traits.htm\r
10 //\r
11 \r
12 /* Release notes:\r
13    01st October 2000:\r
14       Fixed call_traits on VC6, using "poor man's partial specialisation",\r
15       using ideas taken from "Generative programming" by Krzysztof Czarnecki \r
16       & Ulrich Eisenecker.\r
17 */\r
18 \r
19 #ifndef BOOST_OB_CALL_TRAITS_HPP\r
20 #define BOOST_OB_CALL_TRAITS_HPP\r
21 \r
22 #ifndef BOOST_CONFIG_HPP\r
23 #include <boost/config.hpp>\r
24 #endif\r
25 \r
26 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP\r
27 #include <boost/type_traits/arithmetic_traits.hpp>\r
28 #endif\r
29 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP\r
30 #include <boost/type_traits/composite_traits.hpp>\r
31 #endif\r
32 \r
33 namespace boost{\r
34 \r
35 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES\r
36 //\r
37 // use member templates to emulate\r
38 // partial specialisation:\r
39 //\r
40 namespace detail{\r
41 \r
42 template <class T>\r
43 struct standard_call_traits\r
44 {\r
45    typedef T value_type;\r
46    typedef T& reference;\r
47    typedef const T& const_reference;\r
48    typedef const T& param_type;\r
49 };\r
50 template <class T>\r
51 struct simple_call_traits\r
52 {\r
53    typedef T value_type;\r
54    typedef T& reference;\r
55    typedef const T& const_reference;\r
56    typedef const T param_type;\r
57 };\r
58 template <class T>\r
59 struct reference_call_traits\r
60 {\r
61    typedef T value_type;\r
62    typedef T reference;\r
63    typedef T const_reference;\r
64    typedef T param_type;\r
65 };\r
66 \r
67 template <bool pointer, bool arithmetic, bool reference>\r
68 struct call_traits_chooser\r
69 {\r
70    template <class T>\r
71    struct rebind\r
72    {\r
73       typedef standard_call_traits<T> type;\r
74    };\r
75 };\r
76 \r
77 template <>\r
78 struct call_traits_chooser<true, false, false>\r
79 {\r
80    template <class T>\r
81    struct rebind\r
82    {\r
83       typedef simple_call_traits<T> type;\r
84    };\r
85 };\r
86 \r
87 template <>\r
88 struct call_traits_chooser<false, false, true>\r
89 {\r
90    template <class T>\r
91    struct rebind\r
92    {\r
93       typedef reference_call_traits<T> type;\r
94    };\r
95 };\r
96 \r
97 template <bool size_is_small> \r
98 struct call_traits_sizeof_chooser2\r
99 {\r
100    template <class T>\r
101    struct small_rebind\r
102    {\r
103       typedef simple_call_traits<T> small_type;\r
104    };\r
105 };\r
106 \r
107 template<> \r
108 struct call_traits_sizeof_chooser2<false>\r
109 {\r
110    template <class T>\r
111    struct small_rebind\r
112    {\r
113       typedef standard_call_traits<T> small_type;\r
114    };\r
115 };\r
116 \r
117 template <>\r
118 struct call_traits_chooser<false, true, false>\r
119 {\r
120    template <class T>\r
121    struct rebind\r
122    {\r
123       enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) };\r
124       typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser;\r
125       typedef typename chooser::template small_rebind<T> bound_type;\r
126       typedef typename bound_type::small_type type;\r
127    };\r
128 };\r
129 \r
130 } // namespace detail\r
131 template <typename T>\r
132 struct call_traits\r
133 {\r
134 private:\r
135     typedef detail::call_traits_chooser<\r
136          ::boost::is_pointer<T>::value,\r
137          ::boost::is_arithmetic<T>::value, \r
138          ::boost::is_reference<T>::value\r
139       > chooser;\r
140    typedef typename chooser::template rebind<T> bound_type;\r
141    typedef typename bound_type::type call_traits_type;\r
142 public:\r
143    typedef typename call_traits_type::value_type       value_type;\r
144    typedef typename call_traits_type::reference        reference;\r
145    typedef typename call_traits_type::const_reference  const_reference;\r
146    typedef typename call_traits_type::param_type       param_type;\r
147 };\r
148 \r
149 #else\r
150 //\r
151 // sorry call_traits is completely non-functional\r
152 // blame your broken compiler:\r
153 //\r
154 \r
155 template <typename T>\r
156 struct call_traits\r
157 {\r
158    typedef T value_type;\r
159    typedef T& reference;\r
160    typedef const T& const_reference;\r
161    typedef const T& param_type;\r
162 };\r
163 \r
164 #endif // member templates\r
165 \r
166 }\r
167 \r
168 #endif // BOOST_OB_CALL_TRAITS_HPP\r