| 1 |
#pragma once |
| 2 |
|
| 3 |
|
| 4 |
#include "alibxx.hpp" |
| 5 |
|
| 6 |
namespace A_LIB_NAMESPACE{ |
| 7 |
|
| 8 |
namespace Operator { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
// need operator == |
| 13 |
template<typename T, typename O> |
| 14 |
class Equality{ |
| 15 |
public: |
| 16 |
friend bool operator!=(const T& x, const O& y) { return !static_cast<bool>(x == y); } |
| 17 |
}; |
| 18 |
|
| 19 |
|
| 20 |
// need operator == and < |
| 21 |
template<typename T, typename O> |
| 22 |
class Compare{ |
| 23 |
public: |
| 24 |
friend bool operator>(const T& x, const O& y) { return y < x; } |
| 25 |
friend bool operator<=(const T& x, const O& y) { return !static_cast<bool>(y < x); } |
| 26 |
friend bool operator>=(const T& x, const O& y) { return !static_cast<bool>(x < y); } |
| 27 |
|
| 28 |
|
| 29 |
}; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
// need operator += |
| 34 |
template<typename T, typename O> |
| 35 |
class Addable{ |
| 36 |
public: |
| 37 |
friend T operator+(const T& x, const O& y) { T res(x); res+= y; return res; } |
| 38 |
|
| 39 |
}; |
| 40 |
|
| 41 |
template<typename T, typename O> |
| 42 |
class Subtractable{ |
| 43 |
public: |
| 44 |
friend T operator-(const T& x, const O& y) { T res(x); res-= y; return res; } |
| 45 |
|
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
} // A_LIB_NAMESPACE |