| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // accumulators_fwd.hpp |
| 3 | // |
| 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) |
| 7 | |
| 8 | #ifndef BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 |
| 9 | #define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 |
| 10 | |
| 11 | #include <boost/config.hpp> |
| 12 | #include <boost/core/enable_if.hpp> |
| 13 | #include <boost/parameter/is_argument_pack.hpp> |
| 14 | #include <boost/mpl/apply_fwd.hpp> // for mpl::na |
| 15 | #include <boost/mpl/limits/vector.hpp> |
| 16 | #include <boost/preprocessor/cat.hpp> |
| 17 | #include <boost/preprocessor/arithmetic/inc.hpp> |
| 18 | #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> |
| 19 | #include <boost/preprocessor/repetition/enum_trailing_params.hpp> |
| 20 | #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> |
| 21 | #include <boost/preprocessor/repetition/repeat_from_to.hpp> |
| 22 | #include <boost/accumulators/numeric/functional_fwd.hpp> |
| 23 | |
| 24 | #ifndef BOOST_ACCUMULATORS_MAX_FEATURES |
| 25 | /// The maximum number of accumulators that may be put in an accumulator_set. |
| 26 | /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20). |
| 27 | # define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE |
| 28 | #endif |
| 29 | |
| 30 | #if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE |
| 31 | # error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE |
| 32 | #endif |
| 33 | |
| 34 | #ifndef BOOST_ACCUMULATORS_MAX_ARGS |
| 35 | /// The maximum number of arguments that may be specified to an accumulator_set's |
| 36 | /// accumulation function. Defaults to 15. |
| 37 | # define BOOST_ACCUMULATORS_MAX_ARGS 15 |
| 38 | #endif |
| 39 | |
| 40 | #if BOOST_WORKAROUND(__GNUC__, == 3) \ |
| 41 | || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306)) |
| 42 | # define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS |
| 43 | #endif |
| 44 | |
| 45 | #ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS |
| 46 | # include <boost/type_traits/is_const.hpp> |
| 47 | # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\ |
| 48 | , typename boost::disable_if<boost::is_const<T> >::type * = 0 |
| 49 | #else |
| 50 | # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T) |
| 51 | #endif |
| 52 | |
| 53 | #define BOOST_ACCUMULATORS_GCC_VERSION \ |
| 54 | (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) |
| 55 | |
| 56 | namespace boost { namespace accumulators |
| 57 | { |
| 58 | |
| 59 | /////////////////////////////////////////////////////////////////////////////// |
| 60 | // Named parameters tags |
| 61 | // |
| 62 | namespace tag |
| 63 | { |
| 64 | struct sample; |
| 65 | struct weight; |
| 66 | struct accumulator; |
| 67 | struct weights; |
| 68 | } |
| 69 | |
| 70 | /////////////////////////////////////////////////////////////////////////////// |
| 71 | // User-level features |
| 72 | // |
| 73 | namespace tag |
| 74 | { |
| 75 | template<typename ValueType, typename Tag> |
| 76 | struct value; |
| 77 | |
| 78 | template<typename Tag> |
| 79 | struct value_tag; |
| 80 | |
| 81 | template<typename Referent, typename Tag> |
| 82 | struct reference; |
| 83 | |
| 84 | template<typename Tag> |
| 85 | struct reference_tag; |
| 86 | |
| 87 | template<typename Type, typename Tag = void, typename AccumulatorSet = void> |
| 88 | struct external; |
| 89 | |
| 90 | template<typename Feature> |
| 91 | struct droppable; |
| 92 | } |
| 93 | |
| 94 | template<typename Accumulator> |
| 95 | struct droppable_accumulator_base; |
| 96 | |
| 97 | template<typename Accumulator> |
| 98 | struct droppable_accumulator; |
| 99 | |
| 100 | template<typename Accumulator> |
| 101 | struct with_cached_result; |
| 102 | |
| 103 | template<typename Sample, typename Features, typename Weight = void> |
| 104 | struct accumulator_set; |
| 105 | |
| 106 | template<typename Feature> |
| 107 | struct ; |
| 108 | |
| 109 | template<typename Feature> |
| 110 | struct feature_of; |
| 111 | |
| 112 | template<typename Feature> |
| 113 | struct as_feature; |
| 114 | |
| 115 | template<typename Feature> |
| 116 | struct as_weighted_feature; |
| 117 | |
| 118 | template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> |
| 119 | struct depends_on; |
| 120 | |
| 121 | template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> |
| 122 | struct features; |
| 123 | |
| 124 | template<typename Feature, typename AccumulatorSet> |
| 125 | typename mpl::apply<AccumulatorSet, Feature>::type const & |
| 126 | find_accumulator(AccumulatorSet const &acc); |
| 127 | |
| 128 | template<typename Feature, typename AccumulatorSet> |
| 129 | typename mpl::apply<AccumulatorSet, Feature>::type::result_type |
| 130 | (AccumulatorSet const &acc); |
| 131 | |
| 132 | namespace detail |
| 133 | { |
| 134 | struct _enabler |
| 135 | { |
| 136 | }; |
| 137 | } |
| 138 | |
| 139 | // ... other overloads generated by Boost.Preprocessor: |
| 140 | |
| 141 | /// INTERNAL ONLY |
| 142 | /// |
| 143 | #define (z, n, _) \ |
| 144 | template< \ |
| 145 | typename Feature \ |
| 146 | , typename AccumulatorSet \ |
| 147 | BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ |
| 148 | > \ |
| 149 | typename mpl::apply<AccumulatorSet, Feature>::type::result_type \ |
| 150 | ( \ |
| 151 | AccumulatorSet const &acc \ |
| 152 | BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ |
| 153 | , typename boost::enable_if< \ |
| 154 | parameter::is_argument_pack<A0> \ |
| 155 | , detail::_enabler \ |
| 156 | >::type = detail::_enabler() \ |
| 157 | ); \ |
| 158 | template< \ |
| 159 | typename Feature \ |
| 160 | , typename AccumulatorSet \ |
| 161 | BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ |
| 162 | > \ |
| 163 | typename mpl::apply<AccumulatorSet, Feature>::type::result_type \ |
| 164 | ( \ |
| 165 | AccumulatorSet const &acc \ |
| 166 | BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ |
| 167 | , typename boost::disable_if< \ |
| 168 | parameter::is_argument_pack<A0> \ |
| 169 | , detail::_enabler \ |
| 170 | >::type = detail::_enabler() \ |
| 171 | ); |
| 172 | |
| 173 | /// INTERNAL ONLY |
| 174 | /// |
| 175 | BOOST_PP_REPEAT_FROM_TO( |
| 176 | 1 |
| 177 | , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) |
| 178 | , BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD |
| 179 | , _ |
| 180 | ) |
| 181 | |
| 182 | #undef BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD |
| 183 | |
| 184 | #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED |
| 185 | template<typename Feature, typename AccumulatorSet, typename A1, typename A2 ...> |
| 186 | typename mpl::apply<AccumulatorSet, Feature>::type::result_type |
| 187 | extract_result(AccumulatorSet const &acc, A1 const &a1, A2 const &a2 ...); |
| 188 | #endif |
| 189 | |
| 190 | namespace impl |
| 191 | { |
| 192 | using namespace numeric::operators; |
| 193 | |
| 194 | template<typename Accumulator, typename Tag> |
| 195 | struct external_impl; |
| 196 | } |
| 197 | |
| 198 | namespace detail |
| 199 | { |
| 200 | template<typename Accumulator> |
| 201 | struct feature_tag; |
| 202 | |
| 203 | template<typename Feature, typename Sample, typename Weight> |
| 204 | struct to_accumulator; |
| 205 | |
| 206 | struct accumulator_set_base; |
| 207 | |
| 208 | template<typename T> |
| 209 | struct is_accumulator_set; |
| 210 | |
| 211 | inline void ignore_variable(void const *) {} |
| 212 | } |
| 213 | |
| 214 | }} // namespace boost::accumulators |
| 215 | |
| 216 | #define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \ |
| 217 | namespace detail \ |
| 218 | { \ |
| 219 | struct BOOST_PP_CAT(ignore_, X) \ |
| 220 | { \ |
| 221 | void ignore() \ |
| 222 | { \ |
| 223 | boost::accumulators::detail::ignore_variable(&X); \ |
| 224 | } \ |
| 225 | }; \ |
| 226 | } \ |
| 227 | /**/ |
| 228 | |
| 229 | #include <boost/parameter/nested_keyword.hpp> |
| 230 | |
| 231 | #endif // include guard |
| 232 | |
| 233 | |