rippled
Loading...
Searching...
No Matches
comparators.h
1#pragma once
2
3#include <functional>
4
5namespace xrpl {
6
7#ifdef _MSC_VER
8
9/*
10 * MSVC 2019 version 16.9.0 added [[nodiscard]] to the std comparison
11 * operator() functions. boost::bimap checks that the comparator is a
12 * BinaryFunction, in part by calling the function and ignoring the value.
13 * These two things don't play well together. These wrapper classes simply
14 * strip [[nodiscard]] from operator() for use in boost::bimap.
15 *
16 * See also:
17 * https://www.boost.org/doc/libs/1_75_0/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html
18 */
19
20template <class T = void>
21struct less
22{
23 using result_type = bool;
24
25 constexpr bool
26 operator()(T const& left, T const& right) const
27 {
28 return std::less<T>()(left, right);
29 }
30};
31
32template <class T = void>
34{
35 using result_type = bool;
36
37 constexpr bool
38 operator()(T const& left, T const& right) const
39 {
40 return std::equal_to<T>()(left, right);
41 }
42};
43
44#else
45
46template <class T = void>
47using less = std::less<T>;
48
49template <class T = void>
50using equal_to = std::equal_to<T>;
51
52#endif
53
54} // namespace xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr bool operator()(T const &left, T const &right) const
Definition comparators.h:38
bool result_type
Definition comparators.h:23
constexpr bool operator()(T const &left, T const &right) const
Definition comparators.h:26