| 1 |
// Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do compile { target c++20 } } |
| 19 |
|
| 20 |
#include <concepts> |
| 21 |
|
| 22 |
// signed integer types |
| 23 |
static_assert( std::integral<signed char> ); |
| 24 |
static_assert( std::integral<signed short> ); |
| 25 |
static_assert( std::integral<signed int> ); |
| 26 |
static_assert( std::integral<signed long> ); |
| 27 |
static_assert( std::integral<signed long long> ); |
| 28 |
|
| 29 |
// unsigned integer types |
| 30 |
static_assert( std::integral<unsigned char> ); |
| 31 |
static_assert( std::integral<unsigned short> ); |
| 32 |
static_assert( std::integral<unsigned int> ); |
| 33 |
static_assert( std::integral<unsigned long> ); |
| 34 |
static_assert( std::integral<unsigned long long> ); |
| 35 |
|
| 36 |
// other integral types |
| 37 |
static_assert( std::integral<bool> ); |
| 38 |
static_assert( std::integral<char> ); |
| 39 |
static_assert( std::integral<char16_t> ); |
| 40 |
static_assert( std::integral<char32_t> ); |
| 41 |
static_assert( std::integral<wchar_t> ); |
| 42 |
#ifdef _GLIBCXX_USE_CHAR8_T |
| 43 |
static_assert( std::integral<char8_t> ); |
| 44 |
#endif |
| 45 |
|
| 46 |
#ifdef __GLIBCXX_TYPE_INT_N_0 |
| 47 |
static_assert( std::integral<signed __GLIBCXX_TYPE_INT_N_0> ); |
| 48 |
static_assert( std::integral<unsigned __GLIBCXX_TYPE_INT_N_0> ); |
| 49 |
#endif |
| 50 |
|
| 51 |
static_assert( !std::integral<void> ); |
| 52 |
static_assert( !std::integral<float> ); |
| 53 |
static_assert( !std::integral<int*> ); |
| 54 |
static_assert( !std::integral<int&> ); |
| 55 |
static_assert( !std::integral<int&&> ); |
| 56 |
static_assert( !std::integral<const int&> ); |
| 57 |
static_assert( !std::integral<int[]> ); |
| 58 |
static_assert( !std::integral<int[2]> ); |
| 59 |
static_assert( !std::integral<int()> ); |
| 60 |
static_assert( !std::integral<int(*)()> ); |
| 61 |
static_assert( !std::integral<int(&)()> ); |
| 62 |
|
| 63 |
enum E { }; |
| 64 |
static_assert( !std::integral<E> ); |
| 65 |
enum class CE { }; |
| 66 |
static_assert( !std::integral<CE> ); |
| 67 |
struct A { }; |
| 68 |
static_assert( !std::integral<A> ); |
| 69 |
union B { }; |
| 70 |
static_assert( !std::integral<B> ); |