26 #ifndef MLN_FUN_OPS_HH
27 # define MLN_FUN_OPS_HH
33 # include <mln/core/concept/function.hh>
34 # include <mln/fun/internal/selector.hh>
35 # include <mln/trait/all.hh>
39 # define mln_decl_binary_expr_(In, Out, Name, Symbol) \
44 template <typename L, typename R> \
45 struct Name##_##Out##_expr_ \
46 : public Function_##Out < Name##_##Out##_expr_<L,R> > \
48 typedef typename mln::trait::op:: Name < mln_result(L), \
49 mln_result(R) >::ret result; \
51 Name##_##Out##_expr_() \
55 Name##_##Out##_expr_(const L& l, const R& r) \
60 template <typename P> \
61 result operator()(const P& p) const \
63 return l_(p) Symbol r_(p); \
76 template <typename L, typename R> \
77 struct set_binary_< op::Name, \
81 typedef fun::Name##_##Out##_expr_<L,R> ret; \
85 template <typename L, typename R> \
86 fun::Name##_##Out##_expr_<L,R> \
87 operator Symbol (const Function_##In<L>& lhs, const Function_##In<R>& rhs) \
89 fun::Name##_##Out##_expr_<L,R> tmp(exact(lhs), exact(rhs)); \
93 struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
96 # define mln_decl_unary_expr_(In, Out, Name, Symbol) \
101 template <typename F> \
102 struct Name##_##Out##_expr_ \
103 : public Function_##Out< Name##_##Out##_expr_<F> > \
105 typedef typename mln::trait::op:: Name < mln_result(F) >::ret result; \
107 Name##_##Out##_expr_() \
111 Name##_##Out##_expr_(const F& f) \
116 template <typename P> \
117 result operator()(const P& p) const \
119 return Symbol f_(p); \
130 template <typename F> \
131 struct set_unary_< op::Name, \
134 typedef fun::Name##_##Out##_expr_<F> ret; \
138 template <typename F> \
139 fun::Name##_##Out##_expr_<F> \
140 operator Symbol (const Function_##In<F>& f) \
142 fun::Name##_##Out##_expr_<F> tmp(exact(f)); \
146 struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
153 mln_decl_binary_expr_(v2v, v2b, eq, ==);
154 mln_decl_binary_expr_(v2v, v2b, neq, !=);
156 mln_decl_binary_expr_(v2v, v2b, less, <);
157 mln_decl_binary_expr_(v2v, v2b, leq , <=);
158 mln_decl_binary_expr_(v2v, v2b, geq, >=);
159 mln_decl_binary_expr_(v2v, v2b, greater, >);
161 mln_decl_binary_expr_(v2b, v2b,
and_, &&);
162 mln_decl_binary_expr_(v2b, v2b,
or_, ||);
163 mln_decl_binary_expr_(v2b, v2b,
xor_, ^);
165 mln_decl_unary_expr_(v2b, v2b,
not_, !);
167 mln_decl_binary_expr_(v2v, v2v,
plus, +);
168 mln_decl_binary_expr_(v2v, v2v,
minus, -);
169 mln_decl_binary_expr_(v2v, v2v, times, *);
170 mln_decl_binary_expr_(v2v, v2v, div, /);
171 mln_decl_binary_expr_(v2v, v2v, mod, %);
173 mln_decl_unary_expr_(v2v, v2v, uplus, +);
174 mln_decl_unary_expr_(v2v, v2v, uminus, -);
179 #endif // ! MLN_FUN_OPS_HH