Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
OperatorSuppliers.h
Go to the documentation of this file.
1 
11 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_OPERATOR_SUPPLIERS_H
12 #define INCLUDE_MOLASSEMBLER_TEMPLE_OPERATOR_SUPPLIERS_H
13 
14 namespace Scine {
15 namespace Molassembler {
16 namespace Temple {
17 
19 namespace Crtp {
20 
22 template<typename T>
24  constexpr bool operator != (const InequalityFromEquality<T>& other) const {
25  const auto& lhs = static_cast<const T&>(*this);
26  const auto& rhs = static_cast<const T&>(other);
27 
28  return !(lhs == rhs);
29  }
30 };
31 
33 template <typename T>
35  static constexpr const T& derived(const AllOperatorsFromLessThan& base) {
36  return static_cast<const T&>(base);
37  }
38 
39  constexpr bool operator == (const AllOperatorsFromLessThan& other) const {
40  const T& lhs = derived(*this);
41  const T& rhs = derived(other);
42  return !(lhs < rhs) && !(rhs < lhs);
43  }
44 
45  constexpr bool operator != (const AllOperatorsFromLessThan& other) const {
46  const T& lhs = derived(*this);
47  const T& rhs = derived(other);
48  return (lhs < rhs) || (rhs < lhs);
49  }
50 
51  constexpr bool operator > (const AllOperatorsFromLessThan& other) const {
52  return derived(other) < derived(*this);
53  }
54 
55  constexpr bool operator <= (const AllOperatorsFromLessThan& other) const {
56  return !(derived(other) < derived(*this));
57  }
58 
59  constexpr bool operator >= (const AllOperatorsFromLessThan& other) const {
60  return !(derived(*this) < derived(other));
61  }
62 };
63 
77 template<typename T>
79  static constexpr const T& derived(const LexicographicComparable& base) {
80  return static_cast<const T&>(base);
81  }
82 
83  constexpr bool operator == (const LexicographicComparable& other) const {
84  return derived(*this).tie() == derived(other).tie();
85  }
86 
87  constexpr bool operator != (const LexicographicComparable& other) const {
88  return derived(*this).tie() != derived(other).tie();
89  }
90 
91  constexpr bool operator < (const LexicographicComparable& other) const {
92  return derived(*this).tie() < derived(other).tie();
93  }
94 
95  constexpr bool operator <= (const LexicographicComparable& other) const {
96  return derived(*this).tie() <= derived(other).tie();
97  }
98 
99  constexpr bool operator > (const LexicographicComparable& other) const {
100  return derived(*this).tie() > derived(other).tie();
101  }
102 
103  constexpr bool operator >= (const LexicographicComparable& other) const {
104  return derived(*this).tie() >= derived(other).tie();
105  }
106 };
107 
108 } // namespace Crtp
109 } // namespace Temple
110 } // namespace Molassembler
111 } // namespace Scine
112 
113 #endif
Supplies the inequality operator from an implemented equality operator.
Definition: OperatorSuppliers.h:23
Generates all operators using a method returning a tuple.
Definition: OperatorSuppliers.h:78
Supplies all operators from an implemented less-than operator.
Definition: OperatorSuppliers.h:34