1 ///////////////////////////////////////////////////////////////////////////////
2 // accumulators_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_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
9 #define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
11 #include <boost/config.hpp>
12 #include <boost/mpl/apply_fwd.hpp> // for mpl::na
13 #include <boost/mpl/limits/vector.hpp>
14 #include <boost/preprocessor/arithmetic/inc.hpp>
15 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
16 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
17 #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
18 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
19 #include <boost/accumulators/numeric/functional_fwd.hpp>
21 #ifndef BOOST_ACCUMULATORS_MAX_FEATURES
22 /// The maximum number of accumulators that may be put in an accumulator_set.
23 /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20).
24 # define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE
27 #if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE
28 # error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE
31 #ifndef BOOST_ACCUMULATORS_MAX_ARGS
32 /// The maximum number of arguments that may be specified to an accumulator_set's
33 /// accumulation function. Defaults to 15.
34 # define BOOST_ACCUMULATORS_MAX_ARGS 15
37 #if BOOST_WORKAROUND(__GNUC__, == 3) \
38 || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306))
39 # define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
42 #ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
43 # include <boost/utility/enable_if.hpp>
44 # include <boost/type_traits/is_const.hpp>
45 # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\
46 , typename boost::disable_if<boost::is_const<T> >::type * = 0
48 # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)
51 namespace boost
{ namespace accumulators
54 ///////////////////////////////////////////////////////////////////////////////
55 // Named parameters tags
65 ///////////////////////////////////////////////////////////////////////////////
66 // User-level features
70 template<typename ValueType
, typename Tag
>
73 template<typename Tag
>
76 template<typename Referent
, typename Tag
>
79 template<typename Tag
>
82 template<typename Type
, typename Tag
= void, typename AccumulatorSet
= void>
85 template<typename Feature
>
89 template<typename Accumulator
>
90 struct droppable_accumulator_base
;
92 template<typename Accumulator
>
93 struct droppable_accumulator
;
95 template<typename Accumulator
>
96 struct with_cached_result
;
98 template<typename Sample
, typename Features
, typename Weight
= void>
99 struct accumulator_set
;
101 template<typename Feature
>
104 template<typename Feature
>
107 template<typename Feature
>
110 template<typename Feature
>
111 struct as_weighted_feature
;
113 template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES
, typename Feature
, mpl::na
)>
116 template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES
, typename Feature
, mpl::na
)>
119 template<typename Feature
, typename AccumulatorSet
>
120 typename
mpl::apply
<AccumulatorSet
, Feature
>::type
const &
121 find_accumulator(AccumulatorSet
const &acc
);
123 template<typename Feature
, typename AccumulatorSet
>
124 typename
mpl::apply
<AccumulatorSet
, Feature
>::type::result_type
125 extract_result(AccumulatorSet
const &acc
);
127 template<typename Feature
, typename AccumulatorSet
, typename A1
>
128 typename
mpl::apply
<AccumulatorSet
, Feature
>::type::result_type
129 extract_result(AccumulatorSet
const &acc
, A1
const &a1
);
131 // ... other overloads generated by Boost.Preprocessor:
135 #define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \
138 , typename AccumulatorSet \
139 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
141 typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
143 AccumulatorSet const &acc \
144 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
149 BOOST_PP_REPEAT_FROM_TO(
151 , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS
)
152 , BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
156 #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
157 template<typename Feature
, typename AccumulatorSet
, typename A1
, typename A2
...>
158 typename
mpl::apply
<AccumulatorSet
, Feature
>::type::result_type
159 extract_result(AccumulatorSet
const &acc
, A1
const &a1
, A2
const &a2
...);
164 using namespace numeric::operators
;
166 template<typename Accumulator
, typename Tag
>
167 struct external_impl
;
172 template<typename Accumulator
>
175 template<typename Feature
, typename Sample
, typename Weight
>
176 struct to_accumulator
;
178 struct accumulator_set_base
;
181 struct is_accumulator_set
;
184 }} // namespace boost::accumulators
186 // For defining boost::parameter keywords that can be inherited from to
187 // get a nested, class-scoped keyword with the requested alias
188 #define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \
189 namespace tag_namespace \
191 template<int Dummy = 0> \
194 static char const* keyword_name() \
198 static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \
200 template<int Dummy> \
201 ::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \
202 ::boost::parameter::keyword<name ## _<Dummy> >::get(); \
203 typedef name ## _ <> name; \
207 ::boost::parameter::keyword<tag_namespace::name> &name = \
208 ::boost::parameter::keyword<tag_namespace::name>::get(); \