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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: libcpp-no-concepts
11 
12 // template<class T>
13 // concept integral = // see below
14 
15 #include <concepts>
16 #include <type_traits>
17 
18 #include "arithmetic.h"
19 
20 template <typename T>
CheckIntegralQualifiers()21 constexpr bool CheckIntegralQualifiers() {
22   constexpr bool result = std::integral<T>;
23   static_assert(std::integral<const T> == result);
24   static_assert(std::integral<volatile T> == result);
25   static_assert(std::integral<const volatile T> == result);
26 
27   static_assert(!std::integral<T&>);
28   static_assert(!std::integral<const T&>);
29   static_assert(!std::integral<volatile T&>);
30   static_assert(!std::integral<const volatile T&>);
31 
32   static_assert(!std::integral<T&&>);
33   static_assert(!std::integral<const T&&>);
34   static_assert(!std::integral<volatile T&&>);
35   static_assert(!std::integral<const volatile T&&>);
36 
37   static_assert(!std::integral<T*>);
38   static_assert(!std::integral<const T*>);
39   static_assert(!std::integral<volatile T*>);
40   static_assert(!std::integral<const volatile T*>);
41 
42   static_assert(!std::integral<T (*)()>);
43   static_assert(!std::integral<T (&)()>);
44   static_assert(!std::integral<T(&&)()>);
45 
46   return result;
47 }
48 
49 // standard signed and unsigned integers
50 static_assert(CheckIntegralQualifiers<signed char>());
51 static_assert(CheckIntegralQualifiers<unsigned char>());
52 static_assert(CheckIntegralQualifiers<short>());
53 static_assert(CheckIntegralQualifiers<unsigned short>());
54 static_assert(CheckIntegralQualifiers<int>());
55 static_assert(CheckIntegralQualifiers<unsigned int>());
56 static_assert(CheckIntegralQualifiers<long>());
57 static_assert(CheckIntegralQualifiers<unsigned long>());
58 static_assert(CheckIntegralQualifiers<long long>());
59 static_assert(CheckIntegralQualifiers<unsigned long long>());
60 
61 // extended integers
62 #ifndef _LIBCPP_HAS_NO_INT128
63 static_assert(CheckIntegralQualifiers<__int128_t>());
64 static_assert(CheckIntegralQualifiers<__uint128_t>());
65 #endif
66 
67 // bool and char types are also integral
68 static_assert(CheckIntegralQualifiers<wchar_t>());
69 static_assert(CheckIntegralQualifiers<bool>());
70 static_assert(CheckIntegralQualifiers<char>());
71 static_assert(CheckIntegralQualifiers<char8_t>());
72 static_assert(CheckIntegralQualifiers<char16_t>());
73 static_assert(CheckIntegralQualifiers<char32_t>());
74 
75 // types that aren't integral
76 static_assert(!std::integral<void>);
77 static_assert(!CheckIntegralQualifiers<float>());
78 static_assert(!CheckIntegralQualifiers<double>());
79 static_assert(!CheckIntegralQualifiers<long double>());
80 
81 static_assert(!CheckIntegralQualifiers<ClassicEnum>());
82 
83 static_assert(!CheckIntegralQualifiers<ScopedEnum>());
84 
85 static_assert(!CheckIntegralQualifiers<EmptyStruct>());
86 static_assert(!CheckIntegralQualifiers<int EmptyStruct::*>());
87 static_assert(!CheckIntegralQualifiers<int (EmptyStruct::*)()>());
88 
89 static_assert(CheckSubsumption(0));
90 static_assert(CheckSubsumption(0U));
91 
main(int,char **)92 int main(int, char**) { return 0; }
93