KSS Utility
C++ general utilities
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
add_rel_ops.hpp
Go to the documentation of this file.
1 //
2 // add_rel_ops.hpp
3 // kssutil
4 //
5 // Created by Steven W. Klassen on 2018-04-26.
6 // Copyright © 2018 Klassen Software Solutions. All rights reserved.
7 // Licensing follows the MIT License.
8 //
9 
15 #ifndef kssutil_add_rel_ops_hpp
16 #define kssutil_add_rel_ops_hpp
17 
18 
19 namespace kss { namespace util {
20 
30  template <class T>
31  struct AddRelOps {
32  inline bool operator!=(const T& t) const noexcept {
33  const T* self = static_cast<const T*>(this);
34  return !(*self == t);
35  }
36 
37  inline bool operator<=(const T& t) const noexcept {
38  const T* self = static_cast<const T*>(this);
39  return (*self < t || *self == t);
40  }
41 
42  inline bool operator>(const T& t) const noexcept {
43  const T* self = static_cast<const T*>(this);
44  return (!(*self == t) && !(*self < t));
45  }
46 
47  inline bool operator>=(const T& t) const noexcept {
48  const T* self = static_cast<const T*>(this);
49  return !(*self < t);
50  }
51  };
52 
53 }}
54 
55 #endif
bool operator<=(const T &t) const noexcept
Definition: add_rel_ops.hpp:37
bool operator!=(const T &t) const noexcept
Definition: add_rel_ops.hpp:32
bool operator>(const T &t) const noexcept
Definition: add_rel_ops.hpp:42
bool operator>=(const T &t) const noexcept
Definition: add_rel_ops.hpp:47
Add the operators !=, &lt;=, &gt; and &gt;= assuming the existance of == and &lt;.
Definition: add_rel_ops.hpp:31