xref: /llvm-project/libcxx/include/__type_traits/unwrap_ref.h (revision 6f684816e25d8b4e5fb2cbc7d0560d608a8bd938)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
10 #define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
11 
12 #include <__config>
13 #include <__fwd/functional.h>
14 #include <__type_traits/decay.h>
15 
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19 
20 _LIBCPP_BEGIN_NAMESPACE_STD
21 
22 template <class _Tp>
23 struct __unwrap_reference {
24   using type _LIBCPP_NODEBUG = _Tp;
25 };
26 
27 template <class _Tp>
28 struct __unwrap_reference<reference_wrapper<_Tp> > {
29   using type _LIBCPP_NODEBUG = _Tp&;
30 };
31 
32 template <class _Tp>
33 using __unwrap_ref_decay_t _LIBCPP_NODEBUG = typename __unwrap_reference<__decay_t<_Tp> >::type;
34 
35 #if _LIBCPP_STD_VER >= 20
36 template <class _Tp>
37 struct _LIBCPP_NO_SPECIALIZATIONS unwrap_reference : __unwrap_reference<_Tp> {};
38 
39 template <class _Tp>
40 using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
41 
42 template <class _Tp>
43 struct _LIBCPP_NO_SPECIALIZATIONS unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {};
44 
45 template <class _Tp>
46 using unwrap_ref_decay_t = __unwrap_ref_decay_t<_Tp>;
47 #endif // _LIBCPP_STD_VER >= 20
48 
49 _LIBCPP_END_NAMESPACE_STD
50 
51 #endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
52