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_IS_REFERENCE_H |
10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H |
11 | |
12 | #include <__config> |
13 | #include <__type_traits/integral_constant.h> |
14 | |
15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
16 | # pragma GCC system_header |
17 | #endif |
18 | |
19 | _LIBCPP_BEGIN_NAMESPACE_STD |
20 | |
21 | #if __has_builtin(__is_lvalue_reference) && \ |
22 | __has_builtin(__is_rvalue_reference) && \ |
23 | __has_builtin(__is_reference) |
24 | |
25 | template<class _Tp> |
26 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; |
27 | |
28 | template<class _Tp> |
29 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; |
30 | |
31 | template<class _Tp> |
32 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; |
33 | |
34 | #if _LIBCPP_STD_VER > 14 |
35 | template <class _Tp> |
36 | inline constexpr bool is_reference_v = __is_reference(_Tp); |
37 | template <class _Tp> |
38 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); |
39 | template <class _Tp> |
40 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); |
41 | #endif |
42 | |
43 | #else // __has_builtin(__is_lvalue_reference) && etc... |
44 | |
45 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; |
46 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; |
47 | |
48 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; |
49 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; |
50 | |
51 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; |
52 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; |
53 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; |
54 | |
55 | #if _LIBCPP_STD_VER > 14 |
56 | template <class _Tp> |
57 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
58 | |
59 | template <class _Tp> |
60 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; |
61 | |
62 | template <class _Tp> |
63 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; |
64 | #endif |
65 | |
66 | #endif // __has_builtin(__is_lvalue_reference) && etc... |
67 | |
68 | _LIBCPP_END_NAMESPACE_STD |
69 | |
70 | #endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H |
71 | |