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).
6 // See http://www.boost.org/libs/utility for most recent version including documentation.
8 // Crippled version for crippled compilers:
9 // see libs/utility/call_traits.htm
14 Fixed call_traits on VC6, using "poor man's partial specialisation",
15 using ideas taken from "Generative programming" by Krzysztof Czarnecki
19 #ifndef BOOST_OB_CALL_TRAITS_HPP
20 #define BOOST_OB_CALL_TRAITS_HPP
22 #ifndef BOOST_CONFIG_HPP
23 #include <boost/config.hpp>
26 #ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
27 #include <boost/type_traits/arithmetic_traits.hpp>
29 #ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
30 #include <boost/type_traits/composite_traits.hpp>
35 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
37 // use member templates to emulate
38 // partial specialisation:
43 struct standard_call_traits
47 typedef const T
& const_reference
;
48 typedef const T
& param_type
;
51 struct simple_call_traits
55 typedef const T
& const_reference
;
56 typedef const T param_type
;
59 struct reference_call_traits
63 typedef T const_reference
;
67 template <bool pointer
, bool arithmetic
, bool reference
>
68 struct call_traits_chooser
73 typedef standard_call_traits
<T
> type
;
78 struct call_traits_chooser
<true, false, false>
83 typedef simple_call_traits
<T
> type
;
88 struct call_traits_chooser
<false, false, true>
93 typedef reference_call_traits
<T
> type
;
97 template <bool size_is_small
>
98 struct call_traits_sizeof_chooser2
103 typedef simple_call_traits
<T
> small_type
;
108 struct call_traits_sizeof_chooser2
<false>
113 typedef standard_call_traits
<T
> small_type
;
118 struct call_traits_chooser
<false, true, false>
123 enum { sizeof_choice
= (sizeof(T
) <= sizeof(void*)) };
124 typedef call_traits_sizeof_chooser2
<(sizeof(T
) <= sizeof(void*))> chooser
;
125 typedef typename
chooser::template small_rebind
<T
> bound_type
;
126 typedef typename
bound_type::small_type type
;
130 } // namespace detail
131 template <typename T
>
135 typedef detail::call_traits_chooser
<
136 ::boost::is_pointer
<T
>::value
,
137 ::boost::is_arithmetic
<T
>::value
,
138 ::boost::is_reference
<T
>::value
140 typedef typename
chooser::template rebind
<T
> bound_type
;
141 typedef typename
bound_type::type call_traits_type
;
143 typedef typename
call_traits_type::value_type value_type
;
144 typedef typename
call_traits_type::reference reference
;
145 typedef typename
call_traits_type::const_reference const_reference
;
146 typedef typename
call_traits_type::param_type param_type
;
151 // sorry call_traits is completely non-functional
152 // blame your broken compiler:
155 template <typename T
>
158 typedef T value_type
;
159 typedef T
& reference
;
160 typedef const T
& const_reference
;
161 typedef const T
& param_type
;
164 #endif // member templates
168 #endif // BOOST_OB_CALL_TRAITS_HPP