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) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference)
22 
23 template <class _Tp>
24 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};
25 
26 template <class _Tp>
27 struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {};
28 
29 template <class _Tp>
30 struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {};
31 
32 #  if _LIBCPP_STD_VER >= 17
33 template <class _Tp>
34 inline constexpr bool is_reference_v = __is_reference(_Tp);
35 template <class _Tp>
36 inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
37 template <class _Tp>
38 inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
39 #  endif
40 
41 #else // __has_builtin(__is_lvalue_reference) && etc...
42 
43 template <class _Tp>
44 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
45 template <class _Tp>
46 struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
47 
48 template <class _Tp>
49 struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
50 template <class _Tp>
51 struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
52 
53 template <class _Tp>
54 struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
55 template <class _Tp>
56 struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
57 template <class _Tp>
58 struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
59 
60 #  if _LIBCPP_STD_VER >= 17
61 template <class _Tp>
62 inline constexpr bool is_reference_v = is_reference<_Tp>::value;
63 
64 template <class _Tp>
65 inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
66 
67 template <class _Tp>
68 inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
69 #  endif
70 
71 #endif // __has_builtin(__is_lvalue_reference) && etc...
72 
73 _LIBCPP_END_NAMESPACE_STD
74 
75 #endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H
76