xref: /freebsd/contrib/llvm-project/libcxx/include/__type_traits/remove_reference.h (revision a114ece3e6158f49088b0704b4afef07040d83f3)
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_REMOVE_REFERENCE_H
10 #define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
11 
12 #include <__config>
13 
14 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15 #  pragma GCC system_header
16 #endif
17 
18 _LIBCPP_BEGIN_NAMESPACE_STD
19 
20 #if __has_builtin(__remove_reference_t)
21 template <class _Tp>
22 struct _LIBCPP_NO_SPECIALIZATIONS remove_reference {
23   using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
24 };
25 
26 template <class _Tp>
27 using __libcpp_remove_reference_t _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
28 #elif __has_builtin(__remove_reference)
29 template <class _Tp>
30 struct remove_reference {
31   using type _LIBCPP_NODEBUG = __remove_reference(_Tp);
32 };
33 
34 template <class _Tp>
35 using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type;
36 #else
37 // clang-format off
38 template <class _Tp> struct remove_reference        {using type _LIBCPP_NODEBUG = _Tp;};
39 template <class _Tp> struct remove_reference<_Tp&>  {using type _LIBCPP_NODEBUG = _Tp;};
40 template <class _Tp> struct remove_reference<_Tp&&> {using type _LIBCPP_NODEBUG = _Tp;};
41 // clang-format on
42 
43 template <class _Tp>
44 using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type;
45 #endif // __has_builtin(__remove_reference_t)
46 
47 #if _LIBCPP_STD_VER >= 14
48 template <class _Tp>
49 using remove_reference_t = __libcpp_remove_reference_t<_Tp>;
50 #endif
51 
52 _LIBCPP_END_NAMESPACE_STD
53 
54 #endif // _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
55