CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Comparisons.hh
Go to the documentation of this file.
1 #ifndef CASM_Comparisons
2 #define CASM_Comparisons
3 
4 #include "casm/misc/CRTPBase.hh"
5 
6 namespace notstd {
7 
24 template <typename Base>
25 struct Comparisons : public Base {
26  using Base::derived;
27  typedef typename Base::MostDerived MostDerived;
28 
29  bool operator>(const MostDerived &B) const { return B < derived(); };
30 
31  bool operator<=(const MostDerived &B) const { return !(B < derived()); };
32 
33  bool operator>=(const MostDerived &B) const { return !(derived() < B); };
34 
35  bool operator==(const MostDerived &B) const { return derived().eq_impl(B); };
36 
37  bool operator!=(const MostDerived &B) const { return derived().ne_impl(B); };
38 
39  protected:
40  bool eq_impl(const MostDerived &B) const {
41  return (!(derived() < B) && !(B < derived()));
42  };
43 
44  bool ne_impl(const MostDerived &B) const { return !derived().eq_impl(B); };
45 };
46 
47 } // namespace notstd
48 
49 namespace CASM {
50 template <typename Base>
52 }
53 
54 #endif
Main CASM namespace.
Definition: APICommand.hh:8
Non-std smart pointer classes and functions.
Implements other comparisons in terms of '<'.
Definition: Comparisons.hh:25
bool operator<=(const MostDerived &B) const
Definition: Comparisons.hh:31
bool operator==(const MostDerived &B) const
Definition: Comparisons.hh:35
bool ne_impl(const MostDerived &B) const
Definition: Comparisons.hh:44
Base::MostDerived MostDerived
Definition: Comparisons.hh:27
bool operator>=(const MostDerived &B) const
Definition: Comparisons.hh:33
bool operator!=(const MostDerived &B) const
Definition: Comparisons.hh:37
bool eq_impl(const MostDerived &B) const
Definition: Comparisons.hh:40
bool operator>(const MostDerived &B) const
Definition: Comparisons.hh:29