1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___TYPE_TRAITS_DECAY_H
10 #define _LIBCPP___TYPE_TRAITS_DECAY_H
13 #include <__type_traits/add_pointer.h>
14 #include <__type_traits/conditional.h>
15 #include <__type_traits/is_array.h>
16 #include <__type_traits/is_function.h>
17 #include <__type_traits/is_referenceable.h>
18 #include <__type_traits/remove_cv.h>
19 #include <__type_traits/remove_extent.h>
20 #include <__type_traits/remove_reference.h>
22 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23 # pragma GCC system_header
26 _LIBCPP_BEGIN_NAMESPACE_STD
28 #if __has_builtin(__decay)
30 using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
34 using type _LIBCPP_NODEBUG = __decay_t<_Tp>;
38 template <class _Up, bool>
40 typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type;
44 struct __decay<_Up, true> {
46 typedef _LIBCPP_NODEBUG typename conditional<
48 __add_pointer_t<__remove_extent_t<_Up> >,
49 typename conditional<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> >::type >::type
54 struct _LIBCPP_TEMPLATE_VIS decay {
56 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
59 typedef _LIBCPP_NODEBUG typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type type;
63 using __decay_t = typename decay<_Tp>::type;
64 #endif // __has_builtin(__decay)
66 #if _LIBCPP_STD_VER >= 14
68 using decay_t = __decay_t<_Tp>;
71 _LIBCPP_END_NAMESPACE_STD
73 #endif // _LIBCPP___TYPE_TRAITS_DECAY_H