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