DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
comparisonOperators.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Cody R. Drisko. All rights reserved.
2// Licensed under the MIT License. See the LICENSE file in the project root for more information.
3//
4// Name: comparisonOperators.hpp
5// Author: crdrisko
6// Date: 09/17/2020-12:36:17
7// Description: An alternative to std::rel_opts which doesn't inject the comparison operators into the global namespace
8
9#ifndef DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_UTILITIES_OPERATORS_COMPARISONOPERATORS_HPP
10#define DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_UTILITIES_OPERATORS_COMPARISONOPERATORS_HPP
11
13
15{
22 template<typename Derived, typename Empty = PotentiallyEmptyBaseClass<Derived>>
23 class EqualityComparable : public Empty
24 {
25 public:
26 constexpr friend bool operator!=(const Derived& x1_, const Derived& x2_) { return !(x1_ == x2_); }
27 };
28
35 template<typename Derived, typename Empty = PotentiallyEmptyBaseClass<Derived>>
36 class LessThanComparable : public Empty
37 {
38 public:
39 constexpr friend bool operator>(const Derived& x1_, const Derived& x2_) { return x2_ < x1_; }
40 constexpr friend bool operator<=(const Derived& x1_, const Derived& x2_) { return !(x2_ < x1_); }
41 constexpr friend bool operator>=(const Derived& x1_, const Derived& x2_) { return !(x1_ < x2_); }
42 };
43
53 template<typename Derived, typename Empty = PotentiallyEmptyBaseClass<Derived>>
54 class CompletelyComparable : public EqualityComparable<Derived, LessThanComparable<Derived, Empty>>
55 {
56 };
57} // namespace CppUtils::Operators
58
59#endif
Definition comparisonOperators.hpp:55
Definition comparisonOperators.hpp:24
constexpr friend bool operator!=(const Derived &x1_, const Derived &x2_)
Definition comparisonOperators.hpp:26
Definition comparisonOperators.hpp:37
constexpr friend bool operator>(const Derived &x1_, const Derived &x2_)
Definition comparisonOperators.hpp:39
constexpr friend bool operator<=(const Derived &x1_, const Derived &x2_)
Definition comparisonOperators.hpp:40
constexpr friend bool operator>=(const Derived &x1_, const Derived &x2_)
Definition comparisonOperators.hpp:41
Definition comparisonOperators.hpp:15