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