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