-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomparison_function_object.cpp
More file actions
executable file
·48 lines (39 loc) · 1.02 KB
/
Copy pathcomparison_function_object.cpp
File metadata and controls
executable file
·48 lines (39 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright David Stone 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module;
#include <operators/forward.hpp>
export module bounded.comparison_function_object;
import bounded.comparison;
import std_module;
namespace bounded {
template<typename Bound>
struct unary_equal_to {
constexpr explicit unary_equal_to(Bound && bound):
m_bound(OPERATORS_FORWARD(bound))
{
}
constexpr auto operator()(auto const & other) const {
if constexpr (std::is_reference_v<Bound>) {
return m_bound.get() == other;
} else {
return m_bound == other;
}
}
private:
using storage = std::conditional_t<
std::is_reference_v<Bound>,
std::reference_wrapper<std::remove_reference_t<Bound>>,
Bound
>;
storage m_bound;
};
export constexpr auto equal_to() {
return std::equal_to();
}
export template<typename T>
constexpr auto equal_to(T && t) {
return unary_equal_to<T>(OPERATORS_FORWARD(t));
}
} // namespace bounded