fix doc example typo
[boost.git] / boost / accumulators / accumulators_fwd.hpp
blobc88ff695eb74ae899afb3eeaac8c059a850628d3
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)
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
25 #endif
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
29 #endif
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
35 #endif
37 #if BOOST_WORKAROUND(__GNUC__, == 3) \
38 || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306))
39 # define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
40 #endif
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
47 #else
48 # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)
49 #endif
51 namespace boost { namespace accumulators
54 ///////////////////////////////////////////////////////////////////////////////
55 // Named parameters tags
57 namespace tag
59 struct sample;
60 struct weight;
61 struct accumulator;
62 struct weights;
65 ///////////////////////////////////////////////////////////////////////////////
66 // User-level features
68 namespace tag
70 template<typename ValueType, typename Tag>
71 struct value;
73 template<typename Tag>
74 struct value_tag;
76 template<typename Referent, typename Tag>
77 struct reference;
79 template<typename Tag>
80 struct reference_tag;
82 template<typename Type, typename Tag = void, typename AccumulatorSet = void>
83 struct external;
85 template<typename Feature>
86 struct droppable;
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>
102 struct extractor;
104 template<typename Feature>
105 struct feature_of;
107 template<typename Feature>
108 struct as_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)>
114 struct depends_on;
116 template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)>
117 struct features;
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:
133 /// INTERNAL ONLY
135 #define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \
136 template< \
137 typename Feature \
138 , typename AccumulatorSet \
139 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
141 typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
142 extract_result( \
143 AccumulatorSet const &acc \
144 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
147 /// INTERNAL ONLY
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 ...);
160 #endif
162 namespace impl
164 using namespace numeric::operators;
166 template<typename Accumulator, typename Tag>
167 struct external_impl;
170 namespace detail
172 template<typename Accumulator>
173 struct feature_tag;
175 template<typename Feature, typename Sample, typename Weight>
176 struct to_accumulator;
178 struct accumulator_set_base;
180 template<typename T>
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> \
192 struct name ## _ \
194 static char const* keyword_name() \
196 return #name; \
198 static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \
199 }; \
200 template<int Dummy> \
201 ::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \
202 ::boost::parameter::keyword<name ## _<Dummy> >::get(); \
203 typedef name ## _ <> name; \
205 namespace \
207 ::boost::parameter::keyword<tag_namespace::name> &name = \
208 ::boost::parameter::keyword<tag_namespace::name>::get(); \
211 #endif