[5284] | 1 | #ifndef COMPARE_TO_OPERATORS_HPP_
|
---|
| 2 | #define COMPARE_TO_OPERATORS_HPP_
|
---|
| 3 |
|
---|
| 4 | namespace ariba {
|
---|
| 5 | namespace addressing {
|
---|
| 6 | namespace detail {
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * This class implements some convenient operators for the compare_to method.
|
---|
| 11 | *
|
---|
| 12 | * @author Sebastian Mies <mies@tm.uka.de>
|
---|
| 13 | */
|
---|
| 14 | template<class T>
|
---|
| 15 | class compare_to_operators {
|
---|
| 16 | public:
|
---|
| 17 | /// convenience method for comparison of addresses
|
---|
| 18 | inline bool operator==( const T& rhs ) const {
|
---|
| 19 | return static_cast<const T*>(this)->compare_to(rhs) == 0;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | /// convenience method for comparison of addresses
|
---|
| 23 | inline bool operator!=( const T& rhs ) const {
|
---|
| 24 | return static_cast<const T*>(this)->compare_to(rhs) != 0;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | /// convenience method for comparison of addresses
|
---|
| 28 | inline bool operator<( const T& rhs ) const {
|
---|
| 29 | return static_cast<const T*>(this)->compare_to(rhs) < 0;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | /// convenience method for comparison of addresses
|
---|
| 33 | inline bool operator<=( const T& rhs ) const {
|
---|
| 34 | return static_cast<const T*>(this)->compare_to(rhs) <= 0;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /// convenience method for comparison of addresses
|
---|
| 38 | inline bool operator>( const T& rhs ) const {
|
---|
| 39 | return static_cast<const T*>(this)->compare_to(rhs) > 0;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | /// convenience method for comparison of addresses
|
---|
| 43 | inline bool operator>=( const T& rhs ) const {
|
---|
| 44 | return static_cast<const T*>(this)->compare_to(rhs) >= 0;
|
---|
| 45 | }
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 | }}} // namespace ariba::addressing::detail
|
---|
| 49 |
|
---|
| 50 | #endif /* COMPARE_TO_OPERATORS_HPP_ */
|
---|