stlab
2.4.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
Toggle main menu visibility
Loading...
Searching...
No Matches
functional.hpp
Go to the documentation of this file.
1
/*
2
Copyright 2017 Adobe
3
Distributed under the Boost Software License, Version 1.0.
4
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
*/
6
7
/**************************************************************************************************/
8
9
#ifndef STLAB_FUNCTIONAL_HPP
10
#define STLAB_FUNCTIONAL_HPP
11
15
16
/**************************************************************************************************/
17
18
#include <stlab/config.hpp>
19
20
#include <functional>
21
#include <type_traits>
22
23
/**************************************************************************************************/
24
25
namespace
stlab
{
26
STLAB_VERSION_NAMESPACE_BEGIN()
27
28
32
33
/**************************************************************************************************/
34
35
36
template <class T>
37
struct
unwrap_reference
{
38
using
type = T;
39
};
40
41
template
<
class
T>
42
struct
unwrap_reference
<std::reference_wrapper<T>> {
43
using
type = T;
44
};
45
46
template
<
class
T>
47
using
unwrap_reference_t =
typename
unwrap_reference<T>::type;
48
49
/**************************************************************************************************/
50
51
template
<
class
T>
52
struct
is_reference_wrapper
: std::false_type {};
53
template
<
class
T>
54
struct
is_reference_wrapper
<std::reference_wrapper<T>> : std::true_type {};
55
56
template
<
class
T>
57
constexpr
bool
is_reference_wrapper_v =
is_reference_wrapper<T>::value
;
58
59
/**************************************************************************************************/
60
62
template
<
typename
T>
63
auto
unwrap
(T& val) -> T& {
64
return
val;
65
}
66
67
template
<
typename
T>
68
auto
unwrap
(
const
T& val) ->
const
T& {
69
return
val;
70
}
71
72
template
<
typename
T>
73
auto
unwrap
(std::reference_wrapper<T>& val) -> T& {
74
return
val.get();
75
}
76
77
template
<
typename
T>
78
auto
unwrap
(
const
std::reference_wrapper<T>& val) ->
const
T& {
79
return
val.get();
80
}
81
82
/**************************************************************************************************/
83
85
86
STLAB_VERSION_NAMESPACE_END()
87
}
// namespace stlab
88
89
/**************************************************************************************************/
90
91
#endif
92
93
/**************************************************************************************************/
stlab::unwrap
auto unwrap(T &val) -> T &
Unwraps val, forwarding through std::reference_wrapper when present.
Definition
functional.hpp:63
stlab
Definition
reverse.hpp:28
stlab::is_reference_wrapper
Definition
functional.hpp:52
stlab::unwrap_reference
Type alias: T, or the referent type if T is std::reference_wrapper<U>.
Definition
functional.hpp:37
stlab
functional.hpp
Generated by
1.18.0