proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
Ordering.h
Go to the documentation of this file.
1
/*
2
* Copyright 2018-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
namespace
folly
{
20
21
enum class
ordering
: int {
lt
= -1,
eq
= 0,
gt
= 1 };
22
23
template
<
typename
T>
24
constexpr
ordering
to_ordering
(
T
c
) {
25
return
ordering
(
int
(c <
T
(0)) * -1 +
int
(c >
T
(0)));
26
}
27
28
namespace
detail
{
29
30
template
<
typename
C, ordering o,
bool
ne>
31
struct
cmp_pred
:
private
C
{
32
using
C::C
;
33
34
template
<
typename
A,
typename
B>
35
constexpr
bool
operator()
(
A
&&
a
,
B
&&
b
)
const
{
36
return
ne ^ (C::operator()(static_cast<A&&>(
a
), static_cast<B&&>(
b
)) == o);
37
}
38
};
39
40
}
// namespace detail
41
42
template
<
typename
C>
43
struct
compare_equal_to
:
detail::cmp_pred
<C, ordering::eq, 0> {
44
using
detail::cmp_pred<C, ordering::eq, 0>::cmp_pred
;
45
};
46
47
template
<
typename
C>
48
struct
compare_not_equal_to
:
detail::cmp_pred
<C, ordering::eq, 1> {
49
using
detail::cmp_pred<C, ordering::eq, 1>::cmp_pred
;
50
};
51
52
template
<
typename
C>
53
struct
compare_less
:
detail::cmp_pred
<C, ordering::lt, 0> {
54
using
detail::cmp_pred<C, ordering::lt, 0>::cmp_pred
;
55
};
56
57
template
<
typename
C>
58
struct
compare_less_equal
:
detail::cmp_pred
<C, ordering::gt, 1> {
59
using
detail::cmp_pred<C, ordering::gt, 1>::cmp_pred
;
60
};
61
62
template
<
typename
C>
63
struct
compare_greater
:
detail::cmp_pred
<C, ordering::gt, 0> {
64
using
detail::cmp_pred<C, ordering::gt, 0>::cmp_pred
;
65
};
66
67
template
<
typename
C>
68
struct
compare_greater_equal
:
detail::cmp_pred
<C, ordering::lt, 1> {
69
using
detail::cmp_pred<C, ordering::lt, 1>::cmp_pred
;
70
};
71
72
}
// namespace folly
folly::ordering::gt
folly::compare_equal_to
Definition:
Ordering.h:43
folly::to_ordering
constexpr ordering to_ordering(T c)
Definition:
Ordering.h:24
folly::A
std::unique_ptr< int > A
Definition:
ThenCompileTest.h:26
folly::ordering::eq
b
char b
Definition:
OptionalTest.cpp:53
folly::compare_less_equal
Definition:
Ordering.h:58
folly::T
folly::std T
folly
—— Concurrent Priority Queue Implementation ——
Definition:
AtomicBitSet.h:29
detail
Definition:
HashBenchmark.cpp:32
folly::detail::cmp_pred::operator()
constexpr bool operator()(A &&a, B &&b) const
Definition:
Ordering.h:35
folly::compare_less
Definition:
Ordering.h:53
folly::compare_greater_equal
Definition:
Ordering.h:68
folly::ordering
ordering
Definition:
Ordering.h:21
folly::detail::cmp_pred
Definition:
Ordering.h:31
a
char a
Definition:
OptionalTest.cpp:53
C
#define C(name, bit)
Definition:
CpuId.h:204
folly::ordering::lt
folly::compare_not_equal_to
Definition:
Ordering.h:48
folly::compare_greater
Definition:
Ordering.h:63
folly::B
Definition:
ThenCompileTest.h:27
c
char c
Definition:
OptionalTest.cpp:53
proxygen
folly
folly
lang
Ordering.h
Generated by
1.8.11