1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file functional_fwd.hpp
4 // Copyright 2005 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
9 #define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
11 #include <boost/mpl/if.hpp>
12 #include <boost/mpl/placeholders.hpp>
13 #include <boost/utility/enable_if.hpp>
14 #include <boost/type_traits/is_same.hpp>
15 #include <boost/type_traits/is_const.hpp>
17 namespace boost { namespace numeric
19 // For using directives -- this namespace may be re-opened elsewhere
32 using namespace operators;
46 struct tag<T volatile>
51 struct tag<T const volatile>
58 template<typename A0, typename A1>
64 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op) \
65 namespace functional \
67 template<typename Arg, typename EnableIf = void> \
68 struct Name ## _base; \
69 template<typename Arg, typename ArgTag = typename tag<Arg>::type> \
78 extern op::Name const &Name; \
83 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name) \
84 namespace functional \
86 template<typename Left, typename Right, typename EnableIf = void> \
87 struct result_of_ ## Name; \
88 template<typename Left, typename Right, typename EnableIf = void> \
89 struct Name ## _base; \
93 , typename LeftTag = typename tag<Left>::type \
94 , typename RightTag = typename tag<Right>::type \
104 extern op::Name const &Name; \
107 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus)
108 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus)
109 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies)
110 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides)
111 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus)
112 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater)
113 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal)
114 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less)
115 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal)
116 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to)
117 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to)
119 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign)
120 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign)
121 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign)
122 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign)
123 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign)
124 BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign)
126 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +)
127 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -)
128 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~)
129 BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !)
131 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP
132 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP
137 template<typename To, typename From, typename EnableIf = void>
139 template<typename Left, typename Right, typename EnableIf = void>
140 struct min_assign_base;
141 template<typename Left, typename Right, typename EnableIf = void>
142 struct max_assign_base;
143 template<typename Left, typename Right, typename EnableIf = void>
145 template<typename Arg, typename EnableIf = void>
147 template<typename Arg, typename EnableIf = void>
149 template<typename Arg, typename EnableIf = void>
151 template<typename Arg, typename EnableIf = void>
154 template<typename To, typename From, typename ToTag = typename tag<To>::type, typename FromTag = typename tag<From>::type>
156 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
158 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
160 template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
162 template<typename Arg, typename Tag = typename tag<Arg>::type>
164 template<typename Arg, typename Tag = typename tag<Arg>::type>
166 template<typename Arg, typename Tag = typename tag<Arg>::type>
168 template<typename Arg, typename Tag = typename tag<Arg>::type>
174 template<typename To>
187 extern op::min_assign const &min_assign;
188 extern op::max_assign const &max_assign;
189 extern op::fdiv const &fdiv;
190 extern op::as_min const &as_min;
191 extern op::as_max const &as_max;
192 extern op::as_zero const &as_zero;
193 extern op::as_one const &as_one;
196 template<typename To, typename From>
197 typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type
200 template<typename To, typename From>
201 typename mpl::if_<is_same<To const, From const>, To const &, To const>::type
202 promote(From const &from);
214 struct one_or_default;
217 struct zero_or_default;
219 }} // namespace boost::numeric