1 // Copyright (C) 2019-2021 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-options "-std=gnu++2a" } 19 // { dg-do compile { target c++2a } } 20 21 #include <concepts> 22 23 // signed integer types 24 static_assert( std::signed_integral<signed char> ); 25 static_assert( std::signed_integral<signed short> ); 26 static_assert( std::signed_integral<signed int> ); 27 static_assert( std::signed_integral<signed long> ); 28 static_assert( std::signed_integral<signed long long> ); 29 30 // unsigned integer types 31 static_assert( !std::signed_integral<unsigned char> ); 32 static_assert( !std::signed_integral<unsigned short> ); 33 static_assert( !std::signed_integral<unsigned int> ); 34 static_assert( !std::signed_integral<unsigned long> ); 35 static_assert( !std::signed_integral<unsigned long long> ); 36 37 // other integral types 38 static_assert( !std::signed_integral<bool> ); 39 static_assert( std::is_signed_v<char> ? std::signed_integral<char> : true ); 40 static_assert( !std::signed_integral<char16_t> ); 41 static_assert( !std::signed_integral<char32_t> ); 42 static_assert( std::is_signed_v<wchar_t> ? std::signed_integral<wchar_t> : true ); 43 #ifdef _GLIBCXX_USE_CHAR8_T 44 static_assert( !std::signed_integral<char8_t> ); 45 #endif 46 47 #ifdef __GLIBCXX_TYPE_INT_N_0 48 static_assert( std::signed_integral<signed __GLIBCXX_TYPE_INT_N_0> ); 49 static_assert( !std::signed_integral<unsigned __GLIBCXX_TYPE_INT_N_0> ); 50 #endif 51 52 static_assert( !std::signed_integral<void> ); 53 static_assert( !std::signed_integral<float> ); 54 static_assert( !std::signed_integral<int&> ); 55 static_assert( !std::signed_integral<int&> ); 56 static_assert( !std::signed_integral<int&&> ); 57 static_assert( !std::signed_integral<const int&> ); 58 static_assert( !std::signed_integral<int[]> ); 59 static_assert( !std::signed_integral<int[2]> ); 60 static_assert( !std::signed_integral<int()> ); 61 static_assert( !std::signed_integral<int(*)()> ); 62 static_assert( !std::signed_integral<int(&)()> ); 63 64 enum E { }; 65 static_assert( !std::signed_integral<E> ); 66 enum class CE { }; 67 static_assert( !std::signed_integral<CE> ); 68 struct A { }; 69 static_assert( !std::signed_integral<A> ); 70 union B { }; 71 static_assert( !std::signed_integral<B> ); 72