27 #ifndef MLN_FUN_V2V_SATURATE_HH
28 # define MLN_FUN_V2V_SATURATE_HH
35 # include <mln/core/concept/function.hh>
36 # include <mln/metal/converts_to.hh>
37 # include <mln/trait/value_.hh>
38 # include <mln/value/cast.hh>
39 # include <mln/convert/from_to.hh>
54 struct saturate :
public Function_v2v< saturate<V> >
57 saturate(
const V& min,
const V& max);
62 V operator()(
const W& w)
const;
66 mutable bool needs_update_;
70 # ifndef MLN_INCLUDE_ONLY
74 saturate<V>::saturate()
83 saturate<V>::saturate(
const V& min,
const V& max)
87 mln_precondition(max > min);
95 saturate<V>::operator()(
const W& w)
const
100 static W min_W, max_W;
103 min_W = mln::value::cast<W>(min_);
104 max_W = mln::value::cast<W>(max_);
105 needs_update_ =
false;
123 # endif // ! MLN_INCLUDE_ONLY
132 #endif // ! MLN_FUN_V2V_SATURATE_HH