Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / accumulators / numeric / detail / function_n.hpp @ 2486

History | View | Annotate | Download (6.6 kB)

1 2486 sjacqu01
// Copyright David Abrahams 2006. Distributed under the Boost
2 2486 sjacqu01
// Software License, Version 1.0. (See accompanying
3 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 2486 sjacqu01
//
5 2486 sjacqu01
// #include guards intentionally disabled.
6 2486 sjacqu01
// #ifndef BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP
7 2486 sjacqu01
// # define BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP
8 2486 sjacqu01
9 2486 sjacqu01
#include <boost/mpl/void.hpp>
10 2486 sjacqu01
#include <boost/mpl/apply.hpp>
11 2486 sjacqu01
12 2486 sjacqu01
#include <boost/preprocessor/control/if.hpp>
13 2486 sjacqu01
#include <boost/preprocessor/cat.hpp>
14 2486 sjacqu01
#include <boost/preprocessor/punctuation/comma_if.hpp>
15 2486 sjacqu01
#include <boost/preprocessor/repetition/enum_params.hpp>
16 2486 sjacqu01
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
17 2486 sjacqu01
#include <boost/preprocessor/repetition/repeat.hpp>
18 2486 sjacqu01
#include <boost/preprocessor/seq/fold_left.hpp>
19 2486 sjacqu01
#include <boost/preprocessor/seq/seq.hpp>
20 2486 sjacqu01
#include <boost/preprocessor/seq/for_each.hpp>
21 2486 sjacqu01
#include <boost/preprocessor/seq/for_each_i.hpp>
22 2486 sjacqu01
#include <boost/preprocessor/seq/for_each_product.hpp>
23 2486 sjacqu01
#include <boost/preprocessor/seq/size.hpp>
24 2486 sjacqu01
#include <boost/type_traits/add_const.hpp>
25 2486 sjacqu01
#include <boost/type_traits/remove_reference.hpp>
26 2486 sjacqu01
27 2486 sjacqu01
namespace boost { namespace detail {
28 2486 sjacqu01
29 2486 sjacqu01
# define BOOST_DETAIL_default_arg(z, n, _)                                      \
30 2486 sjacqu01
    typedef mpl::void_ BOOST_PP_CAT(arg, n);
31 2486 sjacqu01
32 2486 sjacqu01
# define BOOST_DETAIL_function_arg(z, n, _)                                     \
33 2486 sjacqu01
    typedef typename remove_reference<                                          \
34 2486 sjacqu01
        typename add_const< BOOST_PP_CAT(A, n) >::type                          \
35 2486 sjacqu01
    >::type BOOST_PP_CAT(arg, n);
36 2486 sjacqu01
37 2486 sjacqu01
#define BOOST_DETAIL_cat_arg_counts(s, state, n)                                \
38 2486 sjacqu01
    BOOST_PP_IF(                                                                \
39 2486 sjacqu01
        n                                                                       \
40 2486 sjacqu01
      , BOOST_PP_CAT(state, BOOST_PP_CAT(_, n))                                 \
41 2486 sjacqu01
      , state                                                                   \
42 2486 sjacqu01
    )                                                                           \
43 2486 sjacqu01
    /**/
44 2486 sjacqu01
45 2486 sjacqu01
#define function_name                                                           \
46 2486 sjacqu01
    BOOST_PP_SEQ_FOLD_LEFT(                                                     \
47 2486 sjacqu01
        BOOST_DETAIL_cat_arg_counts                                             \
48 2486 sjacqu01
      , BOOST_PP_CAT(function, BOOST_PP_SEQ_HEAD(args))                         \
49 2486 sjacqu01
      , BOOST_PP_SEQ_TAIL(args)(0)                                              \
50 2486 sjacqu01
    )                                                                           \
51 2486 sjacqu01
    /**/
52 2486 sjacqu01
53 2486 sjacqu01
template<typename F>
54 2486 sjacqu01
struct function_name
55 2486 sjacqu01
{
56 2486 sjacqu01
    BOOST_PP_REPEAT(
57 2486 sjacqu01
        BOOST_MPL_LIMIT_METAFUNCTION_ARITY
58 2486 sjacqu01
      , BOOST_DETAIL_default_arg
59 2486 sjacqu01
      , ~
60 2486 sjacqu01
    )
61 2486 sjacqu01
62 2486 sjacqu01
    template<typename Signature>
63 2486 sjacqu01
    struct result {};
64 2486 sjacqu01
65 2486 sjacqu01
#define BOOST_DETAIL_function_result(r, _, n)                                   \
66 2486 sjacqu01
    template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A)>        \
67 2486 sjacqu01
    struct result<This(BOOST_PP_ENUM_PARAMS(n, A))>                             \
68 2486 sjacqu01
    {                                                                           \
69 2486 sjacqu01
        BOOST_PP_REPEAT(n, BOOST_DETAIL_function_arg, ~)                        \
70 2486 sjacqu01
        typedef                                                                 \
71 2486 sjacqu01
            typename BOOST_PP_CAT(mpl::apply, BOOST_MPL_LIMIT_METAFUNCTION_ARITY)<\
72 2486 sjacqu01
                F                                                               \
73 2486 sjacqu01
                BOOST_PP_ENUM_TRAILING_PARAMS(                                  \
74 2486 sjacqu01
                    BOOST_MPL_LIMIT_METAFUNCTION_ARITY                          \
75 2486 sjacqu01
                  , arg                                                         \
76 2486 sjacqu01
                )                                                               \
77 2486 sjacqu01
            >::type                                                             \
78 2486 sjacqu01
        impl;                                                                   \
79 2486 sjacqu01
        typedef typename impl::result_type type;                                \
80 2486 sjacqu01
    };                                                                          \
81 2486 sjacqu01
    /**/
82 2486 sjacqu01
83 2486 sjacqu01
    BOOST_PP_SEQ_FOR_EACH(BOOST_DETAIL_function_result, _, args)
84 2486 sjacqu01
85 2486 sjacqu01
# define arg_type(r, _, i, is_const)                                            \
86 2486 sjacqu01
    BOOST_PP_COMMA_IF(i) BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) &
87 2486 sjacqu01
88 2486 sjacqu01
# define result_(r, n, constness)                                               \
89 2486 sjacqu01
    typename result<                                                            \
90 2486 sjacqu01
        function_name(                                                          \
91 2486 sjacqu01
            BOOST_PP_SEQ_FOR_EACH_I_R(r, arg_type, ~, constness)                \
92 2486 sjacqu01
        )                                                                       \
93 2486 sjacqu01
    >                                                                           \
94 2486 sjacqu01
    /**/
95 2486 sjacqu01
96 2486 sjacqu01
# define param(r, _, i, is_const) BOOST_PP_COMMA_IF(i)                          \
97 2486 sjacqu01
    BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & BOOST_PP_CAT(x, i)
98 2486 sjacqu01
99 2486 sjacqu01
# define param_list(r, n, constness)                                            \
100 2486 sjacqu01
    BOOST_PP_SEQ_FOR_EACH_I_R(r, param, ~, constness)
101 2486 sjacqu01
102 2486 sjacqu01
# define call_operator(r, constness)                                            \
103 2486 sjacqu01
    template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), typename A)>    \
104 2486 sjacqu01
        result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::type               \
105 2486 sjacqu01
    operator ()( param_list(r, BOOST_PP_SEQ_SIZE(constness), constness) ) const \
106 2486 sjacqu01
    {                                                                           \
107 2486 sjacqu01
        typedef result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::impl impl; \
108 2486 sjacqu01
        return impl()(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), x));   \
109 2486 sjacqu01
    }                                                                           \
110 2486 sjacqu01
    /**/
111 2486 sjacqu01
112 2486 sjacqu01
# define const_if0
113 2486 sjacqu01
# define const_if1 const
114 2486 sjacqu01
115 2486 sjacqu01
# define bits(z, n, _) ((0)(1))
116 2486 sjacqu01
117 2486 sjacqu01
# define gen_operator(r, _, n)                                                  \
118 2486 sjacqu01
    BOOST_PP_SEQ_FOR_EACH_PRODUCT_R(                                            \
119 2486 sjacqu01
        r                                                                       \
120 2486 sjacqu01
      , call_operator                                                           \
121 2486 sjacqu01
      , BOOST_PP_REPEAT(n, bits, ~)                                             \
122 2486 sjacqu01
    )                                                                           \
123 2486 sjacqu01
    /**/
124 2486 sjacqu01
125 2486 sjacqu01
    BOOST_PP_SEQ_FOR_EACH(
126 2486 sjacqu01
        gen_operator
127 2486 sjacqu01
      , ~
128 2486 sjacqu01
      , args
129 2486 sjacqu01
    )
130 2486 sjacqu01
131 2486 sjacqu01
# undef bits
132 2486 sjacqu01
# undef const_if1
133 2486 sjacqu01
# undef const_if0
134 2486 sjacqu01
# undef call_operator
135 2486 sjacqu01
# undef param_list
136 2486 sjacqu01
# undef param
137 2486 sjacqu01
# undef result_
138 2486 sjacqu01
# undef default_
139 2486 sjacqu01
# undef arg_type
140 2486 sjacqu01
# undef gen_operator
141 2486 sjacqu01
# undef function_name
142 2486 sjacqu01
143 2486 sjacqu01
# undef args
144 2486 sjacqu01
};
145 2486 sjacqu01
146 2486 sjacqu01
}} // namespace boost::detail
147 2486 sjacqu01
148 2486 sjacqu01
//#endif // BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP