27 #ifndef MLN_CORE_CONCEPT_ACCUMULATOR_HH
28 # define MLN_CORE_CONCEPT_ACCUMULATOR_HH
34 # include <mln/core/concept/proxy.hh>
35 # include <mln/metal/fix_return.hh>
36 # include <mln/metal/const.hh>
37 # include <mln/trait/accumulators.hh>
105 template <
typename T>
110 template <
typename T>
124 template <
typename A>
129 # ifndef MLN_INCLUDE_ONLY
133 template <
typename E>
137 typedef mln_argument(E) argument;
138 typedef mln_result(E) result;
139 typedef mln_q_result(E) q_result;
141 void (E::*m1)() = & E::init;
143 void (E::*m2)(const argument&) = & E::take;
145 void (E::*m3)(const E&) = & E::take;
148 q_result (E::*m4)() const = & E::to_result;
150 q_result (E::*m5)() const = & E::operator q_result;
153 bool (E::*m6)() const = & E::is_valid;
160 template <typename E>
161 template <typename
T>
165 typedef mln_exact(
T) T_;
166 typedef mlc_converts_to(T_, mln_argument(E)) t_is_argument;
167 typedef mlc_converts_to(T_, E) t_is_accumulator;
168 mlc_or(t_is_argument, t_is_accumulator)::check();
171 exact(this)->take_as_init_(t);
174 template <typename E>
175 template <typename
T>
181 exact(
this)->take(t);
187 template <
typename E>
188 template <
typename T>
192 typedef mln_exact(
T) T_;
193 typedef mlc_converts_to(T_, mln_argument(E)) t_is_argument;
194 typedef mlc_converts_to(T_, E) t_is_accumulator;
195 mlc_or(t_is_argument, t_is_accumulator)::check();
201 exact(this)->take_n_times_(n, t);
204 template <typename E>
205 template <typename
T>
207 Accumulator<E>::take_n_times_(
unsigned n, const
T& t)
210 for (
unsigned i = 0; i < n; ++i)
211 exact(
this)->take(t);
217 template <
typename A>
219 from_to_(
const Accumulator<A>& from_, mln_result(A)& to)
221 const A& from =
exact(from_);
223 to = from.to_result();
225 to = mln_result(A)();
229 # endif // ! MLN_INCLUDE_ONLY
234 #endif // ! MLN_CORE_CONCEPT_ACCUMULATOR_HH