1//===-- is_integral type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
15
16namespace LIBC_NAMESPACE::cpp {
17
18// is_integral
19template <typename T> struct is_integral {
20private:
21 template <typename Head, typename... Args>
22 LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
23 return (... || is_same_v<remove_cv_t<Head>, Args>);
24 }
25
26public:
27 LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of<
28 T,
29#ifdef LIBC_TYPES_HAS_INT128
30 __int128_t, __uint128_t,
31#endif
32 char, signed char, unsigned char, short, unsigned short, int,
33 unsigned int, long, unsigned long, long long, unsigned long long, bool>();
34};
35template <typename T>
36LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral<T>::value;
37
38} // namespace LIBC_NAMESPACE::cpp
39
40#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
41

source code of libc/src/__support/CPP/type_traits/is_integral.h