Molassembler  1.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& getDerived(const AllOperatorsFromLessThan& base) {
36  return static_cast<const T&>(base);
37  }
38 
39  constexpr bool operator == (const AllOperatorsFromLessThan& other) const {
40  const T& lhs = getDerived(*this), rhs = getDerived(other);
41 
42  return !(lhs < rhs) && !(rhs < lhs);
43  }
44 
45  constexpr bool operator != (const AllOperatorsFromLessThan& other) const {
46  const T& lhs = getDerived(*this), rhs = getDerived(other);
47 
48  return (lhs < rhs) || (rhs < lhs);
49  }
50 
51  constexpr bool operator > (const AllOperatorsFromLessThan& other) const {
52  const T& lhs = getDerived(*this), rhs = getDerived(other);
53 
54  return rhs < lhs;
55  }
56 
57  constexpr bool operator <= (const AllOperatorsFromLessThan& other) const {
58  const T& lhs = getDerived(*this), rhs = getDerived(other);
59 
60  return !(rhs < lhs);
61  }
62 
63  constexpr bool operator >= (const AllOperatorsFromLessThan& other) const {
64  const T& lhs = getDerived(*this), rhs = getDerived(other);
65 
66  return !(lhs < rhs);
67  }
68 };
69 
83 template<typename T>
85  static constexpr const T& getDerived(const LexicographicComparable& base) {
86  return static_cast<const T&>(base);
87  }
88 
89  constexpr bool operator == (const LexicographicComparable& other) const {
90  return getDerived(*this).tie() == getDerived(other).tie();
91  }
92 
93  constexpr bool operator != (const LexicographicComparable& other) const {
94  return getDerived(*this).tie() != getDerived(other).tie();
95  }
96 
97  constexpr bool operator < (const LexicographicComparable& other) const {
98  return getDerived(*this).tie() < getDerived(other).tie();
99  }
100 
101  constexpr bool operator <= (const LexicographicComparable& other) const {
102  return getDerived(*this).tie() <= getDerived(other).tie();
103  }
104 
105  constexpr bool operator > (const LexicographicComparable& other) const {
106  return getDerived(*this).tie() > getDerived(other).tie();
107  }
108 
109  constexpr bool operator >= (const LexicographicComparable& other) const {
110  return getDerived(*this).tie() >= getDerived(other).tie();
111  }
112 };
113 
114 } // namespace Crtp
115 } // namespace Temple
116 } // namespace Molassembler
117 } // namespace Scine
118 
119 #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:84
Supplies all operators from an implemented less-than operator.
Definition: OperatorSuppliers.h:34