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
24template <class _Tp>
25struct _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {};
26
27# if _LIBCPP_STD_VER >= 17
28template <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
35template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
36template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
37template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
38template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
39template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
40#if _LIBCPP_HAS_WIDE_CHARACTERS
41template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
42#endif
43#if _LIBCPP_HAS_CHAR8_T
44template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
45#endif
46template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
47template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
48template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
49template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
50template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
51template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; };
52template <> struct __libcpp_is_integral<long> { enum { value = 1 }; };
53template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
54template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
55template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
56#if _LIBCPP_HAS_INT128
57template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
58template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
59#endif
60// clang-format on
61
62template <class _Tp>
63struct is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};
64
65# if _LIBCPP_STD_VER >= 17
66template <class _Tp>
67inline 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.

source code of libcxx/include/__type_traits/is_integral.h