Pack required boost code together.
[xy_vsfilter.git] / src / thirdparty / boost_1_47_0 / boost / detail / ob_call_traits.hpp
blobeaf9cbeb076b862d553636c6ff8273c7598213f2
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).
5 //
6 // See http://www.boost.org/libs/utility for most recent version including documentation.
7 //
8 // Crippled version for crippled compilers:
9 // see libs/utility/call_traits.htm
12 /* Release notes:
13 01st October 2000:
14 Fixed call_traits on VC6, using "poor man's partial specialisation",
15 using ideas taken from "Generative programming" by Krzysztof Czarnecki
16 & Ulrich Eisenecker.
19 #ifndef BOOST_OB_CALL_TRAITS_HPP
20 #define BOOST_OB_CALL_TRAITS_HPP
22 #ifndef BOOST_CONFIG_HPP
23 #include <boost/config.hpp>
24 #endif
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
33 namespace boost{
35 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
37 // use member templates to emulate
38 // partial specialisation:
40 namespace detail{
42 template <class T>
43 struct standard_call_traits
45 typedef T value_type;
46 typedef T& reference;
47 typedef const T& const_reference;
48 typedef const T& param_type;
50 template <class T>
51 struct simple_call_traits
53 typedef T value_type;
54 typedef T& reference;
55 typedef const T& const_reference;
56 typedef const T param_type;
58 template <class T>
59 struct reference_call_traits
61 typedef T value_type;
62 typedef T reference;
63 typedef T const_reference;
64 typedef T param_type;
67 template <bool pointer, bool arithmetic, bool reference>
68 struct call_traits_chooser
70 template <class T>
71 struct rebind
73 typedef standard_call_traits<T> type;
77 template <>
78 struct call_traits_chooser<true, false, false>
80 template <class T>
81 struct rebind
83 typedef simple_call_traits<T> type;
87 template <>
88 struct call_traits_chooser<false, false, true>
90 template <class T>
91 struct rebind
93 typedef reference_call_traits<T> type;
97 template <bool size_is_small>
98 struct call_traits_sizeof_chooser2
100 template <class T>
101 struct small_rebind
103 typedef simple_call_traits<T> small_type;
107 template<>
108 struct call_traits_sizeof_chooser2<false>
110 template <class T>
111 struct small_rebind
113 typedef standard_call_traits<T> small_type;
117 template <>
118 struct call_traits_chooser<false, true, false>
120 template <class T>
121 struct rebind
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>
132 struct call_traits
134 private:
135 typedef detail::call_traits_chooser<
136 ::boost::is_pointer<T>::value,
137 ::boost::is_arithmetic<T>::value,
138 ::boost::is_reference<T>::value
139 > chooser;
140 typedef typename chooser::template rebind<T> bound_type;
141 typedef typename bound_type::type call_traits_type;
142 public:
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;
149 #else
151 // sorry call_traits is completely non-functional
152 // blame your broken compiler:
155 template <typename T>
156 struct call_traits
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