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.
7 // See http://www.boost.org for most recent version including documentation.
9 // Crippled version for crippled compilers:
10 // see libs/utility/call_traits.htm
15 Fixed call_traits on VC6, using "poor man's partial specialisation",
16 using ideas taken from "Generative programming" by Krzysztof Czarnecki
20 #ifndef BOOST_OB_CALL_TRAITS_HPP
21 #define BOOST_OB_CALL_TRAITS_HPP
23 #ifndef BOOST_CONFIG_HPP
24 #include <boost/config.hpp>
27 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
28 #include <boost/type_traits/arithmetic_traits.hpp>
30 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
31 #include <boost/type_traits/composite_traits.hpp>
36 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
38 // use member templates to emulate
39 // partial specialisation:
44 struct standard_call_traits
48 typedef const T& const_reference;
49 typedef const T& param_type;
52 struct simple_call_traits
56 typedef const T& const_reference;
57 typedef const T param_type;
60 struct reference_call_traits
64 typedef T const_reference;
68 template <bool pointer, bool arithmetic, bool reference>
69 struct call_traits_chooser
74 typedef standard_call_traits<T> type;
79 struct call_traits_chooser<true, false, false>
84 typedef simple_call_traits<T> type;
89 struct call_traits_chooser<false, false, true>
94 typedef reference_call_traits<T> type;
98 template <bool size_is_small>
99 struct call_traits_sizeof_chooser2
104 typedef simple_call_traits<T> small_type;
109 struct call_traits_sizeof_chooser2<false>
114 typedef standard_call_traits<T> small_type;
119 struct call_traits_chooser<false, true, false>
124 enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) };
125 typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser;
126 typedef typename chooser::template small_rebind<T> bound_type;
127 typedef typename bound_type::small_type type;
131 } // namespace detail
132 template <typename T>
136 typedef detail::call_traits_chooser<
137 ::boost::is_pointer<T>::value,
138 ::boost::is_arithmetic<T>::value,
139 ::boost::is_reference<T>::value
141 typedef typename chooser::template rebind<T> bound_type;
142 typedef typename bound_type::type call_traits_type;
144 typedef typename call_traits_type::value_type value_type;
145 typedef typename call_traits_type::reference reference;
146 typedef typename call_traits_type::const_reference const_reference;
147 typedef typename call_traits_type::param_type param_type;
152 // sorry call_traits is completely non-functional
153 // blame your broken compiler:
156 template <typename T>
159 typedef T value_type;
160 typedef T& reference;
161 typedef const T& const_reference;
162 typedef const T& param_type;
165 #endif // member templates
169 #endif // BOOST_OB_CALL_TRAITS_HPP