27 #ifndef MLN_CORE_ROUTINE_OPS_HH
28 # define MLN_CORE_ROUTINE_OPS_HH
92 # include <mln/trait/op/all.hh>
93 # include <mln/core/concept/object.hh>
94 # include <mln/metal/converts_to.hh>
101 namespace literal {
struct zero_t;
struct one_t; }
114 template <
typename O>
115 struct set_unary_< op::uplus, Object,O > {
typedef O
ret; };
121 template <
typename O>
122 struct set_unary_< op::
uminus, Object,O > {
typedef mln_trait_op_minus(O, O)
ret; };
128 template <typename O>
129 struct set_unary_< op::preinc, Object,O > {
typedef O& ret; };
135 template <
typename O>
136 struct set_unary_< op::predec, Object,O > {
typedef O&
ret; };
142 template <
typename O>
143 struct set_unary_< op::postinc, Object,O > {
typedef O
ret; };
149 template <
typename O>
150 struct set_unary_< op::postdec, Object,O > {
typedef O
ret; };
156 template <
typename O1,
typename O2>
157 struct set_binary_< op::eq, Object,O1, Object,O2 > {
typedef bool ret; };
159 template <
typename O1,
typename O2>
160 struct set_binary_< op::neq, Object,O1, Object,O2 >
167 template <typename O1, typename O2>
168 struct set_binary_< op::less, Object,O1, Object,O2 > {
typedef bool ret; };
170 template <
typename O1,
typename O2>
171 struct set_binary_< op::leq, Object,O1, Object,O2 >
174 typedef mln_trait_op_less(O2, O1) B_;
178 template <typename O1, typename O2>
179 struct set_binary_< op::geq, Object,O1, Object,O2 >
185 template <typename O1, typename O2>
186 struct set_binary_< op::greater, Object,O1, Object,O2 >
189 typedef mln_trait_op_less(O2, O1) ret;
198 template< template <class> class Name,
200 struct set_precise_unary_< Name, const O >
202 typedef mln_trait_unary(Name, O) ret;
205 template< template <class,class> class Name,
206 typename O1, typename O2 >
207 struct set_precise_binary_< Name, O1, const O2 >
209 typedef mln_trait_binary(Name, O1, O2) ret;
212 template< template <class,class> class Name,
213 typename O1, typename O2 >
214 struct set_precise_binary_< Name, const O1, O2 >
216 typedef mln_trait_binary(Name, O1, O2) ret;
219 template< template <class,class> class Name,
220 typename O1, typename O2 >
221 struct set_precise_binary_< Name, const O1, const O2 >
223 typedef mln_trait_binary(Name, O1, O2) ret;
240 template <typename O1, typename O2>
242 operator!=(const Object<O1>& lhs, const Object<O2>&
rhs);
254 template <typename O1, typename O2>
256 operator>(const Object<O1>& lhs, const Object<O2>& rhs);
269 template <typename O1, typename O2>
271 operator>=(const Object<O1>& lhs, const Object<O2>& rhs);
284 template <typename O1, typename O2>
286 operator<=(const Object<O1>& lhs, const Object<O2>& rhs);
293 template <typename O>
294 O operator++(Object<O>& lhs,
int);
301 template <typename O>
302 O operator--(Object<O>& lhs,
int);
309 template <typename O>
310 O& operator++(Object<O>& rhs);
317 template <typename O>
318 O& operator--(Object<O>& rhs);
326 template <typename O>
327 O operator+(const Object<O>& rhs);
337 template <typename O>
338 mln_trait_op_minus(O, O)
339 operator-(const Object<O>& rhs);
350 template <typename L, typename R>
352 operator+=(Object<L>& lhs, const Object<R>& rhs);
363 template <typename L, typename R>
365 operator-=(Object<L>& lhs, const Object<R>& rhs);
376 template <typename L, typename R>
378 operator*=(Object<L>& lhs, const Object<R>& rhs);
389 template <typename L, typename R>
391 operator/=(Object<L>& lhs, const Object<R>& rhs);
402 template <typename L, typename R>
404 operator%=(Object<L>& lhs, const Object<R>& rhs);
408 # ifndef MLN_INCLUDE_ONLY
412 template <
typename L,
typename R>
415 operator+=(Object<L>& lhs,
const Object<R>& rhs)
417 typedef mln_trait_op_plus(L, R) P;
418 mlc_converts_to(P, L)::check();
424 template <typename L, typename R>
427 operator-=(Object<L>& lhs, const Object<R>& rhs)
429 typedef mln_trait_op_minus(L, R) M;
430 mlc_converts_to(M, L)::check();
436 template <typename L, typename R>
439 operator*=(Object<L>& lhs, const Object<R>& rhs)
441 typedef mln_trait_op_times(L, R)
T;
442 mlc_converts_to(T, L)::check();
448 template <typename L, typename R>
451 operator/=(Object<L>& lhs, const Object<R>& rhs)
453 typedef mln_trait_op_div(L, R) D;
454 mlc_converts_to(D, L)::check();
465 template <typename L, typename R>
468 operator%=(Object<L>& lhs, const Object<R>& rhs)
470 typedef mln_trait_op_mod(L, R) M;
471 mlc_converts_to(M, L)::check();
477 template <typename O>
480 operator+(const Object<O>& rhs)
487 template <
typename O>
489 mln_trait_op_minus(O, O)
490 operator-(const Object<O>& rhs)
492 mlc_converts_to(literal::zero_t, O)::check();
493 literal::zero_t* p_zero = 0;
494 return O(*p_zero) -
exact(rhs);
499 template <
typename O>
512 template <
typename O>
525 template <
typename O>
530 literal::one_t* p_one;
531 exact(rhs) -= *p_one;
537 template <
typename O>
542 literal::one_t* p_one;
543 exact(rhs) += *p_one;
549 template <
typename O1,
typename O2>
552 operator!=(const Object<O1>& lhs, const Object<O2>& rhs)
557 template <
typename O1,
typename O2>
560 operator>(const Object<O1>& lhs, const Object<O2>& rhs)
565 template <
typename O1,
typename O2>
568 operator>=(const Object<O1>& lhs, const Object<O2>& rhs)
573 template <
typename O1,
typename O2>
576 operator<=(const Object<O1>& lhs, const Object<O2>& rhs)
582 # endif // ! MLN_INCLUDE_ONLY
587 #endif // ! MLN_CORE_ROUTINE_OPS_HH