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