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
19namespace sparrow
20{
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
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>
59
65 template <typename T>
66 [[nodiscard]] constexpr bool is_reference_wrapper(const T&)
67 {
69 }
70 }
71} // namespace sparrow
constexpr bool is_reference_wrapper(const T &)
Checks if the given type is a reference wrapper.
constexpr bool is_reference_wrapper_v
Functor for comparing two reference wrappers.
bool operator()(const std::reference_wrapper< T > &lhs, const std::reference_wrapper< T > &rhs) const
Hash function object for std::reference_wrapper.
std::size_t operator()(const std::reference_wrapper< T > &ref) const