26 #ifndef MLN_CORE_CONCEPT_ACCUMULATOR_HH
27 # define MLN_CORE_CONCEPT_ACCUMULATOR_HH
33 # include <mln/core/concept/proxy.hh>
34 # include <mln/metal/fix_return.hh>
35 # include <mln/metal/const.hh>
36 # include <mln/trait/accumulators.hh>
43 template <
typename E>
struct Accumulator;
54 from_to_(
const Accumulator<A>& from, mln_result(A)&
to);
63 struct Accumulator<void>
65 typedef Proxy<void> super;
101 template <
typename T>
105 template <
typename T>
106 void take_as_init_(
const T& t);
113 template <
typename T>
117 template <
typename T>
118 void take_n_times_(
unsigned n,
const T& t);
126 # ifndef MLN_INCLUDE_ONLY
137 template <
typename A>
141 const A& from = exact(from_);
143 to = from.to_result();
145 to = mln_result(A)();
156 template <
typename E>
158 Accumulator<E>::Accumulator()
160 typedef mln_argument(E) argument;
161 typedef mln_result(E) result;
162 typedef mln_q_result(E) q_result;
164 void (E::*m1)() = & E::init;
166 void (E::*m2)(const argument&) = & E::take;
168 void (E::*m3)(const E&) = & E::take;
171 q_result (E::*m4)() const = & E::to_result;
173 q_result (E::*m5)() const = & E::operator q_result;
176 bool (E::*m6)() const = & E::is_valid;
183 template <typename E>
184 template <typename T>
189 typedef mlc_converts_to(T_, mln_argument(E)) t_is_argument;
190 typedef mlc_converts_to(T_, E) t_is_accumulator;
191 mlc_or(t_is_argument, t_is_accumulator)::check();
194 exact(
this)->take_as_init_(t);
197 template <
typename E>
198 template <
typename T>
204 exact(
this)->take(t);
210 template <
typename E>
211 template <
typename T>
216 typedef mlc_converts_to(T_, mln_argument(E)) t_is_argument;
217 typedef mlc_converts_to(T_, E) t_is_accumulator;
218 mlc_or(t_is_argument, t_is_accumulator)::check();
224 exact(
this)->take_n_times_(n, t);
227 template <
typename E>
228 template <
typename T>
233 for (
unsigned i = 0; i < n; ++i)
234 exact(
this)->take(t);
237 # endif // ! MLN_INCLUDE_ONLY
242 #endif // ! MLN_CORE_CONCEPT_ACCUMULATOR_HH