Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file functional_fwd.hpp
|
Chris@16
|
3 ///
|
Chris@16
|
4 // Copyright 2005 Eric Niebler. Distributed under the Boost
|
Chris@16
|
5 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
|
Chris@16
|
9 #define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/mpl/if.hpp>
|
Chris@16
|
12 #include <boost/mpl/placeholders.hpp>
|
Chris@16
|
13 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
14 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
15 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost { namespace numeric
|
Chris@16
|
18 {
|
Chris@16
|
19 // For using directives -- this namespace may be re-opened elsewhere
|
Chris@16
|
20 namespace operators
|
Chris@16
|
21 {}
|
Chris@16
|
22
|
Chris@16
|
23 namespace op
|
Chris@16
|
24 {
|
Chris@16
|
25 using mpl::_;
|
Chris@16
|
26 using mpl::_1;
|
Chris@16
|
27 using mpl::_2;
|
Chris@16
|
28 }
|
Chris@16
|
29
|
Chris@16
|
30 namespace functional
|
Chris@16
|
31 {
|
Chris@16
|
32 using namespace operators;
|
Chris@16
|
33
|
Chris@16
|
34 template<typename T>
|
Chris@16
|
35 struct tag
|
Chris@16
|
36 {
|
Chris@16
|
37 typedef void type;
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 template<typename T>
|
Chris@16
|
41 struct tag<T const>
|
Chris@16
|
42 : tag<T>
|
Chris@16
|
43 {};
|
Chris@16
|
44
|
Chris@16
|
45 template<typename T>
|
Chris@16
|
46 struct tag<T volatile>
|
Chris@16
|
47 : tag<T>
|
Chris@16
|
48 {};
|
Chris@16
|
49
|
Chris@16
|
50 template<typename T>
|
Chris@16
|
51 struct tag<T const volatile>
|
Chris@16
|
52 : tag<T>
|
Chris@16
|
53 {};
|
Chris@16
|
54
|
Chris@16
|
55 template<typename T>
|
Chris@16
|
56 struct static_;
|
Chris@16
|
57
|
Chris@16
|
58 template<typename A0, typename A1>
|
Chris@16
|
59 struct are_integral;
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 /// INTERNAL ONLY
|
Chris@16
|
63 ///
|
Chris@16
|
64 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op) \
|
Chris@16
|
65 namespace functional \
|
Chris@16
|
66 { \
|
Chris@16
|
67 template<typename Arg, typename EnableIf = void> \
|
Chris@16
|
68 struct Name ## _base; \
|
Chris@16
|
69 template<typename Arg, typename ArgTag = typename tag<Arg>::type> \
|
Chris@16
|
70 struct Name; \
|
Chris@16
|
71 } \
|
Chris@16
|
72 namespace op \
|
Chris@16
|
73 { \
|
Chris@16
|
74 struct Name; \
|
Chris@16
|
75 } \
|
Chris@16
|
76 namespace \
|
Chris@16
|
77 { \
|
Chris@16
|
78 extern op::Name const &Name; \
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 /// INTERNAL ONLY
|
Chris@16
|
82 ///
|
Chris@16
|
83 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name) \
|
Chris@16
|
84 namespace functional \
|
Chris@16
|
85 { \
|
Chris@16
|
86 template<typename Left, typename Right, typename EnableIf = void> \
|
Chris@16
|
87 struct result_of_ ## Name; \
|
Chris@16
|
88 template<typename Left, typename Right, typename EnableIf = void> \
|
Chris@16
|
89 struct Name ## _base; \
|
Chris@16
|
90 template< \
|
Chris@16
|
91 typename Left \
|
Chris@16
|
92 , typename Right \
|
Chris@16
|
93 , typename LeftTag = typename tag<Left>::type \
|
Chris@16
|
94 , typename RightTag = typename tag<Right>::type \
|
Chris@16
|
95 > \
|
Chris@16
|
96 struct Name; \
|
Chris@16
|
97 } \
|
Chris@16
|
98 namespace op \
|
Chris@16
|
99 { \
|
Chris@16
|
100 struct Name; \
|
Chris@16
|
101 } \
|
Chris@16
|
102 namespace \
|
Chris@16
|
103 { \
|
Chris@16
|
104 extern op::Name const &Name; \
|
Chris@16
|
105 }
|
Chris@16
|
106
|
Chris@16
|
107 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus)
|
Chris@16
|
108 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus)
|
Chris@16
|
109 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies)
|
Chris@16
|
110 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides)
|
Chris@16
|
111 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus)
|
Chris@16
|
112 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater)
|
Chris@16
|
113 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal)
|
Chris@16
|
114 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less)
|
Chris@16
|
115 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal)
|
Chris@16
|
116 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to)
|
Chris@16
|
117 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to)
|
Chris@16
|
118
|
Chris@16
|
119 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign)
|
Chris@16
|
120 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign)
|
Chris@16
|
121 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign)
|
Chris@16
|
122 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign)
|
Chris@16
|
123 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign)
|
Chris@16
|
124 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign)
|
Chris@16
|
125
|
Chris@16
|
126 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +)
|
Chris@16
|
127 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -)
|
Chris@16
|
128 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~)
|
Chris@16
|
129 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !)
|
Chris@16
|
130
|
Chris@16
|
131 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP
|
Chris@16
|
132 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP
|
Chris@16
|
133
|
Chris@16
|
134
|
Chris@16
|
135 namespace functional
|
Chris@16
|
136 {
|
Chris@16
|
137 template<typename To, typename From, typename EnableIf = void>
|
Chris@16
|
138 struct promote_base;
|
Chris@16
|
139 template<typename Left, typename Right, typename EnableIf = void>
|
Chris@16
|
140 struct min_assign_base;
|
Chris@16
|
141 template<typename Left, typename Right, typename EnableIf = void>
|
Chris@16
|
142 struct max_assign_base;
|
Chris@16
|
143 template<typename Left, typename Right, typename EnableIf = void>
|
Chris@16
|
144 struct fdiv_base;
|
Chris@16
|
145 template<typename Arg, typename EnableIf = void>
|
Chris@16
|
146 struct as_min_base;
|
Chris@16
|
147 template<typename Arg, typename EnableIf = void>
|
Chris@16
|
148 struct as_max_base;
|
Chris@16
|
149 template<typename Arg, typename EnableIf = void>
|
Chris@16
|
150 struct as_zero_base;
|
Chris@16
|
151 template<typename Arg, typename EnableIf = void>
|
Chris@16
|
152 struct as_one_base;
|
Chris@16
|
153
|
Chris@16
|
154 template<typename To, typename From, typename ToTag = typename tag<To>::type, typename FromTag = typename tag<From>::type>
|
Chris@16
|
155 struct promote;
|
Chris@16
|
156 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
|
Chris@16
|
157 struct min_assign;
|
Chris@16
|
158 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
|
Chris@16
|
159 struct max_assign;
|
Chris@16
|
160 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
|
Chris@16
|
161 struct fdiv;
|
Chris@16
|
162 template<typename Arg, typename Tag = typename tag<Arg>::type>
|
Chris@16
|
163 struct as_min;
|
Chris@16
|
164 template<typename Arg, typename Tag = typename tag<Arg>::type>
|
Chris@16
|
165 struct as_max;
|
Chris@16
|
166 template<typename Arg, typename Tag = typename tag<Arg>::type>
|
Chris@16
|
167 struct as_zero;
|
Chris@16
|
168 template<typename Arg, typename Tag = typename tag<Arg>::type>
|
Chris@16
|
169 struct as_one;
|
Chris@16
|
170 }
|
Chris@16
|
171
|
Chris@16
|
172 namespace op
|
Chris@16
|
173 {
|
Chris@16
|
174 template<typename To>
|
Chris@16
|
175 struct promote;
|
Chris@16
|
176 struct min_assign;
|
Chris@16
|
177 struct max_assign;
|
Chris@16
|
178 struct fdiv;
|
Chris@16
|
179 struct as_min;
|
Chris@16
|
180 struct as_max;
|
Chris@16
|
181 struct as_zero;
|
Chris@16
|
182 struct as_one;
|
Chris@16
|
183 }
|
Chris@16
|
184
|
Chris@16
|
185 namespace
|
Chris@16
|
186 {
|
Chris@16
|
187 extern op::min_assign const &min_assign;
|
Chris@16
|
188 extern op::max_assign const &max_assign;
|
Chris@16
|
189 extern op::fdiv const &fdiv;
|
Chris@16
|
190 extern op::as_min const &as_min;
|
Chris@16
|
191 extern op::as_max const &as_max;
|
Chris@16
|
192 extern op::as_zero const &as_zero;
|
Chris@16
|
193 extern op::as_one const &as_one;
|
Chris@16
|
194 }
|
Chris@16
|
195
|
Chris@16
|
196 template<typename To, typename From>
|
Chris@16
|
197 typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type
|
Chris@16
|
198 promote(From &from);
|
Chris@16
|
199
|
Chris@16
|
200 template<typename To, typename From>
|
Chris@16
|
201 typename mpl::if_<is_same<To const, From const>, To const &, To const>::type
|
Chris@16
|
202 promote(From const &from);
|
Chris@16
|
203
|
Chris@16
|
204 template<typename T>
|
Chris@16
|
205 struct default_;
|
Chris@16
|
206
|
Chris@16
|
207 template<typename T>
|
Chris@16
|
208 struct one;
|
Chris@16
|
209
|
Chris@16
|
210 template<typename T>
|
Chris@16
|
211 struct zero;
|
Chris@16
|
212
|
Chris@16
|
213 template<typename T>
|
Chris@16
|
214 struct one_or_default;
|
Chris@16
|
215
|
Chris@16
|
216 template<typename T>
|
Chris@16
|
217 struct zero_or_default;
|
Chris@16
|
218
|
Chris@16
|
219 }} // namespace boost::numeric
|
Chris@16
|
220
|
Chris@16
|
221 #endif
|