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 // Crippled version for crippled compilers:
\r
9 // see libs/utility/call_traits.htm
\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
19 #ifndef BOOST_OB_CALL_TRAITS_HPP
\r
20 #define BOOST_OB_CALL_TRAITS_HPP
\r
22 #ifndef BOOST_CONFIG_HPP
\r
23 #include <boost/config.hpp>
\r
26 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
\r
27 #include <boost/type_traits/arithmetic_traits.hpp>
\r
29 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
\r
30 #include <boost/type_traits/composite_traits.hpp>
\r
35 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
\r
37 // use member templates to emulate
\r
38 // partial specialisation:
\r
43 struct standard_call_traits
\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
51 struct simple_call_traits
\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
59 struct reference_call_traits
\r
61 typedef T value_type;
\r
62 typedef T reference;
\r
63 typedef T const_reference;
\r
64 typedef T param_type;
\r
67 template <bool pointer, bool arithmetic, bool reference>
\r
68 struct call_traits_chooser
\r
73 typedef standard_call_traits<T> type;
\r
78 struct call_traits_chooser<true, false, false>
\r
83 typedef simple_call_traits<T> type;
\r
88 struct call_traits_chooser<false, false, true>
\r
93 typedef reference_call_traits<T> type;
\r
97 template <bool size_is_small>
\r
98 struct call_traits_sizeof_chooser2
\r
101 struct small_rebind
\r
103 typedef simple_call_traits<T> small_type;
\r
108 struct call_traits_sizeof_chooser2<false>
\r
111 struct small_rebind
\r
113 typedef standard_call_traits<T> small_type;
\r
118 struct call_traits_chooser<false, true, false>
\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
130 } // namespace detail
\r
131 template <typename T>
\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
140 typedef typename chooser::template rebind<T> bound_type;
\r
141 typedef typename bound_type::type call_traits_type;
\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
151 // sorry call_traits is completely non-functional
\r
152 // blame your broken compiler:
\r
155 template <typename T>
\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
164 #endif // member templates
\r
168 #endif // BOOST_OB_CALL_TRAITS_HPP
\r