rippled
ripple
basics
comparators.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_BASICS_COMPARATORS_H_INCLUDED
21
#define RIPPLE_BASICS_COMPARATORS_H_INCLUDED
22
23
#include <
functional
>
24
25
namespace
ripple
{
26
27
#ifdef _MSC_VER
28
29
/*
30
* MSVC 2019 version 16.9.0 added [[nodiscard]] to the std comparison
31
* operator() functions. boost::bimap checks that the comparitor is a
32
* BinaryFunction, in part by calling the function and ignoring the value.
33
* These two things don't play well together. These wrapper classes simply
34
* strip [[nodiscard]] from operator() for use in boost::bimap.
35
*
36
* See also:
37
* https://www.boost.org/doc/libs/1_75_0/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html
38
*/
39
40
template
<
class
T =
void
>
41
struct
less
42
{
43
using
result_type
= bool;
44
45
constexpr
bool
46
operator()
(
const
T& left,
const
T& right)
const
47
{
48
return
std::less<T>
()(left, right);
49
}
50
};
51
52
template
<
class
T =
void
>
53
struct
equal_to
54
{
55
using
result_type
= bool;
56
57
constexpr
bool
58
operator()
(
const
T& left,
const
T& right)
const
59
{
60
return
std::equal_to<T>
()(left, right);
61
}
62
};
63
64
#else
65
66
template
<
class
T =
void
>
67
using
less =
std::less<T>
;
68
69
template
<
class
T =
void
>
70
using
equal_to =
std::equal_to<T>
;
71
72
#endif
73
74
}
// namespace ripple
75
76
#endif
functional
std::less< T >
ripple::less::result_type
bool result_type
Definition:
comparators.h:43
ripple::equal_to::result_type
bool result_type
Definition:
comparators.h:55
ripple::equal_to
Definition:
comparators.h:53
std::equal_to< T >
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::less
Definition:
comparators.h:41
ripple::less::operator()
constexpr bool operator()(const T &left, const T &right) const
Definition:
comparators.h:46
ripple::equal_to::operator()
constexpr bool operator()(const T &left, const T &right) const
Definition:
comparators.h:58
Generated by
1.8.17