26 #ifndef MLN_FUN_SPE_BINARY_HH
27 # define MLN_FUN_SPE_BINARY_HH
29 # include <mln/core/concept/function.hh>
30 # include <mln/trait/next/solve.hh>
31 # include <mln/trait/functions.hh>
45 template <
typename Fun,
typename T1,
typename T2>
51 template <
bool has_param,
typename Fun,
typename T1,
typename T2>
54 template <
typename Fun,
typename T1,
typename T2>
55 struct binary_impl<false, Fun, T1, T2>
59 typedef mln_trait_nbinary(flag, T1, T2) def;
61 typedef typename def::argument1 argument1;
62 typedef typename def::argument2 argument2;
63 typedef typename def::result result;
65 result operator () (const argument1& a, const argument2& b)
const
67 return def::read(a, b);
72 void init(
const U& value)
79 template <
typename Fun,
typename T1,
typename T2>
80 struct binary_impl<true, Fun, T1, T2>
84 typedef mln_trait_nbinary(flag, T1, T2) def;
86 typedef typename def::argument1 argument1;
87 typedef typename def::argument2 argument2;
88 typedef typename def::result result;
90 typedef mln_trait_fun_param(def) param;
91 typedef mln_trait_fun_storage(def) storage;
93 result operator () (const argument1& a, const argument2& b)
const
95 return def::read(state_, a, b);
99 void init(
const U& value)
101 state_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
104 stored<storage>& state()
109 const stored<storage>& state()
const
115 mln::fun::stored<storage> state_;
120 template <
typename Fun,
typename T1,
typename T2>
122 : impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2>
124 typedef impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2> super;
130 template <
typename U>
131 binary(
const U& param)
133 this->super::init(param);
136 using super::operator();
145 #endif // ! MLN_FUN_SPE_BINARY_HH