26 #ifndef MLN_FUN_P2V_TERNARY_HH
27 # define MLN_FUN_P2V_TERNARY_HH
34 # include <mln/fun/internal/selector.hh>
46 template <
typename P,
typename T,
typename F>
48 : fun::internal::selector_from_result_<mln_result(T), ternary_<P,T,F> >::ret
50 typedef mln_result(T) result;
52 ternary_(const Function_v2b<P>& f_pred,
53 const Function_v2v<T>& f_true,
54 const Function_v2v<F>& f_false);
56 template <typename Pt>
57 result operator()(const Pt& p) const;
66 template <typename P, typename T, typename F>
68 ternary(const Function_v2b<P>& f_pred,
69 const Function_v2v<T>& f_true,
70 const Function_v2v<F>& f_false);
73 # ifndef MLN_INCLUDE_ONLY
75 template <
typename P,
typename T,
typename F>
77 ternary_<P,T,F>::ternary_(
const Function_v2b<P>& f_pred,
78 const Function_v2v<T>& f_true,
79 const Function_v2v<F>& f_false)
80 : f_pred_(exact(f_pred)),
81 f_true_(exact(f_true)),
82 f_false_(exact(f_false))
86 template <
typename P,
typename T,
typename F>
87 template <
typename Pt>
90 ternary_<P,T,F>::operator()(const Pt& p)
const
92 return f_pred_(p) ? f_true_(p) : f_false_(p);
96 template <
typename P,
typename T,
typename F>
99 ternary(
const Function_v2b<P>& f_pred,
100 const Function_v2v<T>& f_true,
101 const Function_v2v<F>& f_false)
103 ternary_<P, T, F> tmp(exact(f_pred),
109 # endif // ! MLN_INCLUDE_ONLY
118 #endif // ! MLN_FUN_P2V_TERNARY_HH