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 template <class _Tp> struct __libcpp_is_integral                     { enum { value = 0 }; };
23 template <>          struct __libcpp_is_integral<bool>               { enum { value = 1 }; };
24 template <>          struct __libcpp_is_integral<char>               { enum { value = 1 }; };
25 template <>          struct __libcpp_is_integral<signed char>        { enum { value = 1 }; };
26 template <>          struct __libcpp_is_integral<unsigned char>      { enum { value = 1 }; };
27 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28 template <>          struct __libcpp_is_integral<wchar_t>            { enum { value = 1 }; };
29 #endif
30 #ifndef _LIBCPP_HAS_NO_CHAR8_T
31 template <>          struct __libcpp_is_integral<char8_t>            { enum { value = 1 }; };
32 #endif
33 template <>          struct __libcpp_is_integral<char16_t>           { enum { value = 1 }; };
34 template <>          struct __libcpp_is_integral<char32_t>           { enum { value = 1 }; };
35 template <>          struct __libcpp_is_integral<short>              { enum { value = 1 }; };
36 template <>          struct __libcpp_is_integral<unsigned short>     { enum { value = 1 }; };
37 template <>          struct __libcpp_is_integral<int>                { enum { value = 1 }; };
38 template <>          struct __libcpp_is_integral<unsigned int>       { enum { value = 1 }; };
39 template <>          struct __libcpp_is_integral<long>               { enum { value = 1 }; };
40 template <>          struct __libcpp_is_integral<unsigned long>      { enum { value = 1 }; };
41 template <>          struct __libcpp_is_integral<long long>          { enum { value = 1 }; };
42 template <>          struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
43 #ifndef _LIBCPP_HAS_NO_INT128
44 template <>          struct __libcpp_is_integral<__int128_t>         { enum { value = 1 }; };
45 template <>          struct __libcpp_is_integral<__uint128_t>        { enum { value = 1 }; };
46 #endif
47 
48 #if __has_builtin(__is_integral)
49 
50 template <class _Tp>
51 struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { };
52 
53 #if _LIBCPP_STD_VER > 14
54 template <class _Tp>
55 inline constexpr bool is_integral_v = __is_integral(_Tp);
56 #endif
57 
58 #else
59 
60 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
61     : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};
62 
63 #if _LIBCPP_STD_VER > 14
64 template <class _Tp>
65 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
66 #endif
67 
68 #endif // __has_builtin(__is_integral)
69 
70 _LIBCPP_END_NAMESPACE_STD
71 
72 #endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H
73