EvolutionOrdering.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <pup.h>
7 #include <utility>
8 
9 /// \ingroup TimeGroup
10 /// Ordering functors that reverse their order when time runs
11 /// backwards.
12 ///
13 /// \see std::less
14 //@{
15 template <typename T = void>
17  bool time_runs_forward = true;
18  constexpr bool operator()(const T& x, const T& y) const noexcept {
19  return time_runs_forward ? x < y : y < x;
20  }
21 
22  // NOLINTNEXTLINE(google-runtime-references)
23  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
24 };
25 
26 template <typename T = void>
28  bool time_runs_forward = true;
29  constexpr bool operator()(const T& x, const T& y) const noexcept {
30  return time_runs_forward ? x > y : y > x;
31  }
32 
33  // NOLINTNEXTLINE(google-runtime-references)
34  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
35 };
36 
37 template <typename T = void>
39  bool time_runs_forward = true;
40  constexpr bool operator()(const T& x, const T& y) const noexcept {
41  return time_runs_forward ? x <= y : y <= x;
42  }
43 
44  // NOLINTNEXTLINE(google-runtime-references)
45  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
46 };
47 
48 template <typename T = void>
50  bool time_runs_forward = true;
51  constexpr bool operator()(const T& x, const T& y) const noexcept {
52  return time_runs_forward ? x >= y : y >= x;
53  }
54 
55  // NOLINTNEXTLINE(google-runtime-references)
56  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
57 };
58 
59 template <>
60 struct evolution_less<void> {
61  bool time_runs_forward = true;
62  template <typename T, typename U>
63  constexpr auto operator()(T&& t, U&& u) const noexcept {
64  return time_runs_forward ? std::forward<T>(t) < std::forward<U>(u)
65  : std::forward<U>(u) < std::forward<T>(t);
66  }
67 
68  // NOLINTNEXTLINE(google-runtime-references)
69  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
70 };
71 
72 template <>
73 struct evolution_greater<void> {
74  bool time_runs_forward = true;
75  template <typename T, typename U>
76  constexpr auto operator()(T&& t, U&& u) const noexcept {
77  return time_runs_forward ? std::forward<T>(t) > std::forward<U>(u)
78  : std::forward<U>(u) > std::forward<T>(t);
79  }
80 
81  // NOLINTNEXTLINE(google-runtime-references)
82  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
83 };
84 
85 template <>
86 struct evolution_less_equal<void> {
87  bool time_runs_forward = true;
88  template <typename T, typename U>
89  constexpr auto operator()(T&& t, U&& u) const noexcept {
90  return time_runs_forward ? std::forward<T>(t) <= std::forward<U>(u)
91  : std::forward<U>(u) <= std::forward<T>(t);
92  }
93 
94  // NOLINTNEXTLINE(google-runtime-references)
95  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
96 };
97 
98 template <>
100  bool time_runs_forward = true;
101  template <typename T, typename U>
102  constexpr auto operator()(T&& t, U&& u) const noexcept {
103  return time_runs_forward ? std::forward<T>(t) >= std::forward<U>(u)
104  : std::forward<U>(u) >= std::forward<T>(t);
105  }
106 
107  // NOLINTNEXTLINE(google-runtime-references)
108  void pup(PUP::er& p) noexcept { p | time_runs_forward; }
109 };
110 //@}
Definition: EvolutionOrdering.hpp:38
Definition: EvolutionOrdering.hpp:27
Ordering functors that reverse their order when time runs backwards.
Definition: EvolutionOrdering.hpp:16
Definition: EvolutionOrdering.hpp:49