sparrow
0.3.0
Loading...
Searching...
No Matches
reference_wrapper_utils.hpp
Go to the documentation of this file.
1
// Copyright 2024 Man Group Operations Limited
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or mplied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include <functional>
18
19
namespace
sparrow
20
{
28
struct
reference_wrapper_hasher
29
{
30
template
<
typename
T>
31
[[nodiscard]] std::size_t
operator()
(
const
std::reference_wrapper<T>& ref)
const
32
{
33
return
std::hash<std::remove_cvref_t<T>>{}(ref.get());
34
}
35
};
36
43
struct
reference_wrapper_equal
44
{
45
template
<
typename
T>
46
bool
operator()
(
const
std::reference_wrapper<T>& lhs,
const
std::reference_wrapper<T>& rhs)
const
47
{
48
return
lhs.get() == rhs.get();
49
}
50
};
51
52
namespace
mpl
53
{
54
template
<
typename
T>
55
constexpr
bool
is_reference_wrapper_v
=
false
;
56
57
template
<
typename
U>
58
constexpr
bool
is_reference_wrapper_v<std::reference_wrapper<U>
> =
true
;
59
65
template
<
typename
T>
66
[[nodiscard]]
constexpr
bool
is_reference_wrapper
(
const
T&)
67
{
68
return
is_reference_wrapper_v<std::remove_cvref_t<T>
>;
69
}
70
}
71
}
// namespace sparrow
sparrow::mpl::is_reference_wrapper
constexpr bool is_reference_wrapper(const T &)
Checks if the given type is a reference wrapper.
Definition
reference_wrapper_utils.hpp:66
sparrow::mpl::is_reference_wrapper_v
constexpr bool is_reference_wrapper_v
Definition
reference_wrapper_utils.hpp:55
sparrow
Definition
array.hpp:21
sparrow::reference_wrapper_equal
Functor for comparing two reference wrappers.
Definition
reference_wrapper_utils.hpp:44
sparrow::reference_wrapper_equal::operator()
bool operator()(const std::reference_wrapper< T > &lhs, const std::reference_wrapper< T > &rhs) const
Definition
reference_wrapper_utils.hpp:46
sparrow::reference_wrapper_hasher
Hash function object for std::reference_wrapper.
Definition
reference_wrapper_utils.hpp:29
sparrow::reference_wrapper_hasher::operator()
std::size_t operator()(const std::reference_wrapper< T > &ref) const
Definition
reference_wrapper_utils.hpp:31
include
sparrow
utils
reference_wrapper_utils.hpp
Generated by
1.13.2