xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
beast
utility
Zero.h
1
// Copyright (c) 2014, Tom Ritchford <tom@swirly.com>
2
3
#pragma once
4
5
namespace
beast
{
6
24
25
struct
Zero
26
{
27
explicit
Zero
() =
default
;
28
};
29
30
inline
constexpr
Zero
kZero
{};
31
35
template
<
typename
T>
36
auto
37
signum
(T
const
& t)
38
{
39
return
t.signum();
40
}
41
42
namespace
detail::zero_helper
{
43
44
// For argument dependent lookup to function properly, calls to signum must
45
// be made from a namespace that does not include overloads of the function..
46
template
<
class
T>
47
auto
48
callSignum
(T
const
& t)
49
{
50
return
signum
(t);
51
}
52
53
}
// namespace detail::zero_helper
54
55
// Handle operators where T is on the left side using signum.
56
57
template
<
typename
T>
58
bool
59
operator==
(T
const
& t,
Zero
)
60
{
61
return
detail::zero_helper::callSignum
(t) == 0;
62
}
63
64
template
<
typename
T>
65
bool
66
operator!=
(T
const
& t,
Zero
)
67
{
68
return
detail::zero_helper::callSignum
(t) != 0;
69
}
70
71
template
<
typename
T>
72
bool
73
operator<
(T
const
& t,
Zero
)
74
{
75
return
detail::zero_helper::callSignum
(t) < 0;
76
}
77
78
template
<
typename
T>
79
bool
80
operator>
(T
const
& t,
Zero
)
81
{
82
return
detail::zero_helper::callSignum
(t) > 0;
83
}
84
85
template
<
typename
T>
86
bool
87
operator>=
(T
const
& t,
Zero
)
88
{
89
return
detail::zero_helper::callSignum
(t) >= 0;
90
}
91
92
template
<
typename
T>
93
bool
94
operator<=
(T
const
& t,
Zero
)
95
{
96
return
detail::zero_helper::callSignum
(t) <= 0;
97
}
98
99
// Handle operators where T is on the right side by
100
// reversing the operation, so that T is on the left side.
101
102
template
<
typename
T>
103
bool
104
operator==
(
Zero
, T
const
& t)
105
{
106
return
t ==
kZero
;
107
}
108
109
template
<
typename
T>
110
bool
111
operator!=
(
Zero
, T
const
& t)
112
{
113
return
t !=
kZero
;
114
}
115
116
template
<
typename
T>
117
bool
118
operator<
(
Zero
, T
const
& t)
119
{
120
return
t >
kZero
;
121
}
122
123
template
<
typename
T>
124
bool
125
operator>
(
Zero
, T
const
& t)
126
{
127
return
t <
kZero
;
128
}
129
130
template
<
typename
T>
131
bool
132
operator>=
(
Zero
, T
const
& t)
133
{
134
return
t <=
kZero
;
135
}
136
137
template
<
typename
T>
138
bool
139
operator<=
(
Zero
, T
const
& t)
140
{
141
return
t >=
kZero
;
142
}
143
144
}
// namespace beast
beast::detail::zero_helper
Definition
Zero.h:42
beast::detail::zero_helper::callSignum
auto callSignum(T const &t)
Definition
Zero.h:48
beast
Definition
base_uint.h:697
beast::operator<=
bool operator<=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition
SemanticVersion.h:85
beast::operator>=
bool operator>=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition
SemanticVersion.h:79
beast::operator>
bool operator>(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition
SemanticVersion.h:91
beast::signum
auto signum(T const &t)
Default implementation of signum calls the method on the class.
Definition
Zero.h:37
beast::operator<
bool operator<(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition
SemanticVersion.h:97
beast::operator==
bool operator==(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
Definition
LockFreeStack.h:88
beast::operator!=
bool operator!=(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
Definition
LockFreeStack.h:97
beast::kZero
constexpr Zero kZero
Definition
Zero.h:30
beast::Zero
Zero allows classes to offer efficient comparisons to zero.
Definition
Zero.h:26
beast::Zero::Zero
Zero()=default
Generated by
1.17.0