Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:19

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file functional_fwd.hpp
0003 ///
0004 //  Copyright 2005 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
0009 #define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005
0010 
0011 #include <boost/mpl/if.hpp>
0012 #include <boost/mpl/placeholders.hpp>
0013 #include <boost/utility/enable_if.hpp>
0014 #include <boost/type_traits/is_same.hpp>
0015 #include <boost/type_traits/is_const.hpp>
0016 
0017 namespace boost { namespace numeric
0018 {
0019     // For using directives -- this namespace may be re-opened elsewhere
0020     namespace operators
0021     {}
0022 
0023     namespace op
0024     {
0025         using mpl::_;
0026         using mpl::_1;
0027         using mpl::_2;
0028     }
0029 
0030     namespace functional
0031     {
0032         using namespace operators;
0033 
0034         template<typename T>
0035         struct tag
0036         {
0037             typedef void type;
0038         };
0039 
0040         template<typename T>
0041         struct tag<T const>
0042           : tag<T>
0043         {};
0044 
0045         template<typename T>
0046         struct tag<T volatile>
0047           : tag<T>
0048         {};
0049 
0050         template<typename T>
0051         struct tag<T const volatile>
0052           : tag<T>
0053         {};
0054 
0055         template<typename T>
0056         struct static_;
0057 
0058         template<typename A0, typename A1>
0059         struct are_integral;
0060     }
0061 
0062     /// INTERNAL ONLY
0063     ///
0064 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op)                                     \
0065     namespace functional                                                                        \
0066     {                                                                                           \
0067         template<typename Arg, typename EnableIf = void>                                        \
0068         struct Name ## _base;                                                                   \
0069         template<typename Arg, typename ArgTag = typename tag<Arg>::type>                       \
0070         struct Name;                                                                            \
0071     }                                                                                           \
0072     namespace op                                                                                \
0073     {                                                                                           \
0074         struct Name;                                                                            \
0075     }                                                                                           \
0076     namespace                                                                                   \
0077     {                                                                                           \
0078         extern op::Name const &Name;                                                            \
0079     }
0080 
0081     /// INTERNAL ONLY
0082     ///
0083 #define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name)                                        \
0084     namespace functional                                                                        \
0085     {                                                                                           \
0086         template<typename Left, typename Right, typename EnableIf = void>                       \
0087         struct result_of_ ## Name;                                                              \
0088         template<typename Left, typename Right, typename EnableIf = void>                       \
0089         struct Name ## _base;                                                                   \
0090         template<                                                                               \
0091             typename Left                                                                       \
0092           , typename Right                                                                      \
0093           , typename LeftTag = typename tag<Left>::type                                         \
0094           , typename RightTag = typename tag<Right>::type                                       \
0095         >                                                                                       \
0096         struct Name;                                                                            \
0097     }                                                                                           \
0098     namespace op                                                                                \
0099     {                                                                                           \
0100         struct Name;                                                                            \
0101     }                                                                                           \
0102     namespace                                                                                   \
0103     {                                                                                           \
0104         extern op::Name const &Name;                                                            \
0105     }
0106 
0107     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus)
0108     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus)
0109     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies)
0110     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides)
0111     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus)
0112     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater)
0113     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal)
0114     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less)
0115     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal)
0116     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to)
0117     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to)
0118 
0119     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign)
0120     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign)
0121     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign)
0122     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign)
0123     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign)
0124     BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign)
0125 
0126     BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +)
0127     BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -)
0128     BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~)
0129     BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !)
0130 
0131 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP
0132 #undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP
0133 
0134 
0135     namespace functional
0136     {
0137         template<typename To, typename From, typename EnableIf = void>
0138         struct promote_base;
0139         template<typename Left, typename Right, typename EnableIf = void>
0140         struct min_assign_base;
0141         template<typename Left, typename Right, typename EnableIf = void>
0142         struct max_assign_base;
0143         template<typename Left, typename Right, typename EnableIf = void>
0144         struct fdiv_base;
0145         template<typename Arg, typename EnableIf = void>
0146         struct as_min_base;
0147         template<typename Arg, typename EnableIf = void>
0148         struct as_max_base;
0149         template<typename Arg, typename EnableIf = void>
0150         struct as_zero_base;
0151         template<typename Arg, typename EnableIf = void>
0152         struct as_one_base;
0153 
0154         template<typename To, typename From, typename ToTag = typename tag<To>::type, typename FromTag = typename tag<From>::type>
0155         struct promote;
0156         template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
0157         struct min_assign;
0158         template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
0159         struct max_assign;
0160         template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
0161         struct fdiv;
0162         template<typename Arg, typename Tag = typename tag<Arg>::type>
0163         struct as_min;
0164         template<typename Arg, typename Tag = typename tag<Arg>::type>
0165         struct as_max;
0166         template<typename Arg, typename Tag = typename tag<Arg>::type>
0167         struct as_zero;
0168         template<typename Arg, typename Tag = typename tag<Arg>::type>
0169         struct as_one;
0170     }
0171 
0172     namespace op
0173     {
0174         template<typename To>
0175         struct promote;
0176         struct min_assign;
0177         struct max_assign;
0178         struct fdiv;
0179         struct as_min;
0180         struct as_max;
0181         struct as_zero;
0182         struct as_one;
0183     }
0184 
0185     namespace
0186     {
0187         extern op::min_assign const &min_assign;
0188         extern op::max_assign const &max_assign;
0189         extern op::fdiv const &fdiv;
0190         extern op::as_min const &as_min;
0191         extern op::as_max const &as_max;
0192         extern op::as_zero const &as_zero;
0193         extern op::as_one const &as_one;
0194     }
0195 
0196     template<typename To, typename From>
0197     typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type
0198     promote(From &from);
0199 
0200     template<typename To, typename From>
0201     typename mpl::if_<is_same<To const, From const>, To const &, To const>::type
0202     promote(From const &from);
0203 
0204     template<typename T>
0205     struct default_;
0206 
0207     template<typename T>
0208     struct one;
0209 
0210     template<typename T>
0211     struct zero;
0212 
0213     template<typename T>
0214     struct one_or_default;
0215 
0216     template<typename T>
0217     struct zero_or_default;
0218 
0219 }} // namespace boost::numeric
0220 
0221 #endif