]> git.donarmstrong.com Git - rsem.git/blob - boost/detail/ob_call_traits.hpp
Added posterior standard deviation of counts as output if either '--calc-pme' or...
[rsem.git] / boost / detail / ob_call_traits.hpp
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
10 //
11
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.
17 */
18
19 #ifndef BOOST_OB_CALL_TRAITS_HPP
20 #define BOOST_OB_CALL_TRAITS_HPP
21
22 #ifndef BOOST_CONFIG_HPP
23 #include <boost/config.hpp>
24 #endif
25
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
32
33 namespace boost{
34
35 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
36 //
37 // use member templates to emulate
38 // partial specialisation:
39 //
40 namespace detail{
41
42 template <class T>
43 struct standard_call_traits
44 {
45    typedef T value_type;
46    typedef T& reference;
47    typedef const T& const_reference;
48    typedef const T& param_type;
49 };
50 template <class T>
51 struct simple_call_traits
52 {
53    typedef T value_type;
54    typedef T& reference;
55    typedef const T& const_reference;
56    typedef const T param_type;
57 };
58 template <class T>
59 struct reference_call_traits
60 {
61    typedef T value_type;
62    typedef T reference;
63    typedef T const_reference;
64    typedef T param_type;
65 };
66
67 template <bool pointer, bool arithmetic, bool reference>
68 struct call_traits_chooser
69 {
70    template <class T>
71    struct rebind
72    {
73       typedef standard_call_traits<T> type;
74    };
75 };
76
77 template <>
78 struct call_traits_chooser<true, false, false>
79 {
80    template <class T>
81    struct rebind
82    {
83       typedef simple_call_traits<T> type;
84    };
85 };
86
87 template <>
88 struct call_traits_chooser<false, false, true>
89 {
90    template <class T>
91    struct rebind
92    {
93       typedef reference_call_traits<T> type;
94    };
95 };
96
97 template <bool size_is_small> 
98 struct call_traits_sizeof_chooser2
99 {
100    template <class T>
101    struct small_rebind
102    {
103       typedef simple_call_traits<T> small_type;
104    };
105 };
106
107 template<> 
108 struct call_traits_sizeof_chooser2<false>
109 {
110    template <class T>
111    struct small_rebind
112    {
113       typedef standard_call_traits<T> small_type;
114    };
115 };
116
117 template <>
118 struct call_traits_chooser<false, true, false>
119 {
120    template <class T>
121    struct rebind
122    {
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;
127    };
128 };
129
130 } // namespace detail
131 template <typename T>
132 struct call_traits
133 {
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;
147 };
148
149 #else
150 //
151 // sorry call_traits is completely non-functional
152 // blame your broken compiler:
153 //
154
155 template <typename T>
156 struct call_traits
157 {
158    typedef T value_type;
159    typedef T& reference;
160    typedef const T& const_reference;
161    typedef const T& param_type;
162 };
163
164 #endif // member templates
165
166 }
167
168 #endif // BOOST_OB_CALL_TRAITS_HPP