Warning: This file is not a C or C++ file. It does not have highlighting.
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_INTEGRAL_H |
10 | #define _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H |
11 | |
12 | #include <__config> |
13 | #include <__type_traits/integral_constant.h> |
14 | #include <__type_traits/remove_cv.h> |
15 | |
16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
17 | # pragma GCC system_header |
18 | #endif |
19 | |
20 | _LIBCPP_BEGIN_NAMESPACE_STD |
21 | |
22 | #if __has_builtin(__is_integral) |
23 | |
24 | template <class _Tp> |
25 | struct _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {}; |
26 | |
27 | # if _LIBCPP_STD_VER >= 17 |
28 | template <class _Tp> |
29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp); |
30 | # endif |
31 | |
32 | #else |
33 | |
34 | // clang-format off |
35 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; |
36 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; |
37 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; |
38 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; |
39 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; |
40 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
41 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; |
42 | #endif |
43 | #if _LIBCPP_HAS_CHAR8_T |
44 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; |
45 | #endif |
46 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; |
47 | template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; }; |
48 | template <> struct __libcpp_is_integral<short> { enum { value = 1 }; }; |
49 | template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; }; |
50 | template <> struct __libcpp_is_integral<int> { enum { value = 1 }; }; |
51 | template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; }; |
52 | template <> struct __libcpp_is_integral<long> { enum { value = 1 }; }; |
53 | template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; }; |
54 | template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; }; |
55 | template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; }; |
56 | #if _LIBCPP_HAS_INT128 |
57 | template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; |
58 | template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; |
59 | #endif |
60 | // clang-format on |
61 | |
62 | template <class _Tp> |
63 | struct is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {}; |
64 | |
65 | # if _LIBCPP_STD_VER >= 17 |
66 | template <class _Tp> |
67 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
68 | # endif |
69 | |
70 | #endif // __has_builtin(__is_integral) |
71 | |
72 | _LIBCPP_END_NAMESPACE_STD |
73 | |
74 | #endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H |
75 |
Warning: This file is not a C or C++ file. It does not have highlighting.