CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Comparisons.hh
Go to the documentation of this file.
1 #ifndef CASM_Comparisons
2 #define CASM_Comparisons
3 
4 namespace CASM {
5 
22  template<typename Derived>
23  struct Comparisons {
24 
25  bool operator>(const Derived &B) const {
26  return B < derived();
27  };
28 
29  bool operator<=(const Derived &B) const {
30  return !(B < derived());
31  };
32 
33  bool operator>=(const Derived &B) const {
34  return !(derived() < B);
35  };
36 
37  bool operator==(const Derived &B) const {
38  return derived()._eq(B);
39  };
40 
41  bool operator!=(const Derived &B) const {
42  return derived()._ne(B);
43  };
44 
45 
46  protected:
47 
48  const Derived &derived() const {
49  return *static_cast<const Derived *>(this);
50  }
51 
52  bool _eq(const Derived &B) const {
53  return (!(derived() < B) && !(B < derived()));
54  };
55 
56  bool _ne(const Derived &B) const {
57  return !derived()._eq(B);
58  };
59 
60  };
61 
62 }
63 
64 #endif
bool _ne(const Derived &B) const
Definition: Comparisons.hh:56
const Derived & derived() const
Definition: Comparisons.hh:48
Implements other comparisons in terms of '<'.
Definition: Comparisons.hh:23
bool operator>=(const Derived &B) const
Definition: Comparisons.hh:33
bool operator<=(const Derived &B) const
Definition: Comparisons.hh:29
bool operator!=(const Derived &B) const
Definition: Comparisons.hh:41
Main CASM namespace.
Definition: complete.cpp:8
bool operator>(const Derived &B) const
Definition: Comparisons.hh:25
bool _eq(const Derived &B) const
Definition: Comparisons.hh:52
bool operator==(const Derived &B) const
Definition: Comparisons.hh:37