stlab 2.3.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
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
25namespace stlab {
26STLAB_VERSION_NAMESPACE_BEGIN()
27
28
32
33/**************************************************************************************************/
34
35
36template <class T>
38 using type = T;
39};
40
41template <class T>
42struct unwrap_reference<std::reference_wrapper<T>> {
43 using type = T;
44};
45
46template <class T>
47using unwrap_reference_t = typename unwrap_reference<T>::type;
48
49/**************************************************************************************************/
50
51template <class T>
52struct is_reference_wrapper : std::false_type {};
53template <class T>
54struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};
55
56template <class T>
57constexpr bool is_reference_wrapper_v = is_reference_wrapper<T>::value;
58
59/**************************************************************************************************/
60
62template <typename T>
63auto unwrap(T& val) -> T& {
64 return val;
65}
66
67template <typename T>
68auto unwrap(const T& val) -> const T& {
69 return val;
70}
71
72template <typename T>
73auto unwrap(std::reference_wrapper<T>& val) -> T& {
74 return val.get();
75}
76
77template <typename T>
78auto unwrap(const std::reference_wrapper<T>& val) -> const T& {
79 return val.get();
80}
81
82/**************************************************************************************************/
83
85
86STLAB_VERSION_NAMESPACE_END()
87} // namespace stlab
88
89/**************************************************************************************************/
90
91#endif
92
93/**************************************************************************************************/
auto unwrap(T &val) -> T &
Unwraps val, forwarding through std::reference_wrapper when present.
Definition functional.hpp:63
Definition reverse.hpp:28
Definition functional.hpp:52
Type alias: T, or the referent type if T is std::reference_wrapper<U>.
Definition functional.hpp:37