numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
comparators.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
23
24namespace num_collect::util {
25
32template <typename Left, concepts::rhs_less_than_comparable<Left> Right = Left>
33class less {
34public:
42 [[nodiscard]] constexpr auto operator()(
43 const Left& left, const Right& right) const -> bool {
44 return left < right;
45 }
46};
47
54template <typename Left,
55 concepts::rhs_less_than_or_equal_to_comparable<Left> Right = Left>
57public:
65 [[nodiscard]] constexpr auto operator()(
66 const Left& left, const Right& right) const -> bool {
67 return left <= right;
68 }
69};
70
77template <typename Left,
78 concepts::rhs_greater_than_comparable<Left> Right = Left>
79class greater {
80public:
88 [[nodiscard]] constexpr auto operator()(
89 const Left& left, const Right& right) const -> bool {
90 return left > right;
91 }
92};
93
100template <typename Left,
101 concepts::rhs_greater_than_or_equal_to_comparable<Left> Right = Left>
103public:
111 [[nodiscard]] constexpr auto operator()(
112 const Left& left, const Right& right) const -> bool {
113 return left >= right;
114 }
115};
116
123template <typename Left, concepts::rhs_equal_to_comparable<Left> Right = Left>
124class equal {
125public:
133 [[nodiscard]] constexpr auto operator()(
134 const Left& left, const Right& right) const -> bool {
135 return left == right;
136 }
137};
138
145template <typename Left,
146 concepts::rhs_not_equal_to_comparable<Left> Right = Left>
148public:
156 [[nodiscard]] constexpr auto operator()(
157 const Left& left, const Right& right) const -> bool {
158 return left != right;
159 }
160};
161
162} // namespace num_collect::util
Class to compare two values with operator==.
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Class to compare two values with operator>=.
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Class to compare two values with operator>.
Definition comparators.h:79
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Definition comparators.h:88
Class to compare two values with operator<=.
Definition comparators.h:56
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Definition comparators.h:65
Class to compare two values with operator<.
Definition comparators.h:33
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Definition comparators.h:42
Class to compare two values with operator!=.
constexpr auto operator()(const Left &left, const Right &right) const -> bool
Compare.
Namespace of utilities.
Definition assert.h:30
Definition of rhs_comparable concept.