|
| 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 | + |
| 11 | +#include <concepts> |
| 12 | + |
| 13 | +struct SomeObject {}; |
| 14 | + |
| 15 | +// Concept helpers for the internal type traits for the fundamental types. |
| 16 | + |
| 17 | +// template <class _Tp> |
| 18 | +// concept __libcpp_unsigned_integer; |
| 19 | + |
| 20 | +// Unsigned |
| 21 | +static_assert(std::__libcpp_unsigned_integer<unsigned char>); |
| 22 | +static_assert(std::__libcpp_unsigned_integer<unsigned short int>); |
| 23 | +static_assert(std::__libcpp_unsigned_integer<unsigned int>); |
| 24 | +static_assert(std::__libcpp_unsigned_integer<unsigned long int>); |
| 25 | +static_assert(std::__libcpp_unsigned_integer<unsigned long long int>); |
| 26 | +static_assert(std::__libcpp_unsigned_integer<unsigned short int>); |
| 27 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 28 | +static_assert(std::__libcpp_unsigned_integer<__uint128_t>); |
| 29 | +#endif |
| 30 | +// Signed |
| 31 | +static_assert(!std::__libcpp_unsigned_integer<signed char>); |
| 32 | +static_assert(!std::__libcpp_unsigned_integer<short int>); |
| 33 | +static_assert(!std::__libcpp_unsigned_integer<int>); |
| 34 | +static_assert(!std::__libcpp_unsigned_integer<long int>); |
| 35 | +static_assert(!std::__libcpp_unsigned_integer<long long int>); |
| 36 | +static_assert(!std::__libcpp_unsigned_integer<short int>); |
| 37 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 38 | +static_assert(!std::__libcpp_unsigned_integer<__int128_t>); |
| 39 | +#endif |
| 40 | +// Non-integer |
| 41 | +static_assert(!std::__libcpp_unsigned_integer<bool>); |
| 42 | +static_assert(!std::__libcpp_unsigned_integer<char8_t>); |
| 43 | +static_assert(!std::__libcpp_unsigned_integer<char16_t>); |
| 44 | +static_assert(!std::__libcpp_unsigned_integer<char32_t>); |
| 45 | +static_assert(!std::__libcpp_unsigned_integer<float>); |
| 46 | +static_assert(!std::__libcpp_unsigned_integer<double>); |
| 47 | +static_assert(!std::__libcpp_unsigned_integer<long double>); |
| 48 | +static_assert(!std::__libcpp_unsigned_integer<void>); |
| 49 | +static_assert(!std::__libcpp_unsigned_integer<SomeObject>); |
| 50 | + |
| 51 | +// template <class _Tp> |
| 52 | +// concept __libcpp_signed_integer; |
| 53 | + |
| 54 | +// Unsigned |
| 55 | +static_assert(!std::__libcpp_signed_integer<unsigned char>); |
| 56 | +static_assert(!std::__libcpp_signed_integer<unsigned short int>); |
| 57 | +static_assert(!std::__libcpp_signed_integer<unsigned int>); |
| 58 | +static_assert(!std::__libcpp_signed_integer<unsigned long int>); |
| 59 | +static_assert(!std::__libcpp_signed_integer<unsigned long long int>); |
| 60 | +static_assert(!std::__libcpp_signed_integer<unsigned short int>); |
| 61 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 62 | +static_assert(!std::__libcpp_signed_integer<__uint128_t>); |
| 63 | +#endif |
| 64 | +// Signed |
| 65 | +static_assert(std::__libcpp_signed_integer<signed char>); |
| 66 | +static_assert(std::__libcpp_signed_integer<short int>); |
| 67 | +static_assert(std::__libcpp_signed_integer<int>); |
| 68 | +static_assert(std::__libcpp_signed_integer<long int>); |
| 69 | +static_assert(std::__libcpp_signed_integer<long long int>); |
| 70 | +static_assert(std::__libcpp_signed_integer<short int>); |
| 71 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 72 | +static_assert(std::__libcpp_signed_integer<__int128_t>); |
| 73 | +#endif |
| 74 | +// Non-integer |
| 75 | +static_assert(!std::__libcpp_signed_integer<bool>); |
| 76 | +static_assert(!std::__libcpp_signed_integer<char8_t>); |
| 77 | +static_assert(!std::__libcpp_signed_integer<char16_t>); |
| 78 | +static_assert(!std::__libcpp_signed_integer<char32_t>); |
| 79 | +static_assert(!std::__libcpp_signed_integer<float>); |
| 80 | +static_assert(!std::__libcpp_signed_integer<double>); |
| 81 | +static_assert(!std::__libcpp_signed_integer<long double>); |
| 82 | +static_assert(!std::__libcpp_signed_integer<void>); |
| 83 | +static_assert(!std::__libcpp_signed_integer<SomeObject>); |
| 84 | + |
| 85 | +// template <class _Tp> |
| 86 | +// concept __libcpp_integer; |
| 87 | + |
| 88 | +// Unsigned |
| 89 | +static_assert(std::__libcpp_integer<unsigned char>); |
| 90 | +static_assert(std::__libcpp_integer<unsigned short int>); |
| 91 | +static_assert(std::__libcpp_integer<unsigned int>); |
| 92 | +static_assert(std::__libcpp_integer<unsigned long int>); |
| 93 | +static_assert(std::__libcpp_integer<unsigned long long int>); |
| 94 | +static_assert(std::__libcpp_integer<unsigned short int>); |
| 95 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 96 | +static_assert(std::__libcpp_integer<__uint128_t>); |
| 97 | +#endif |
| 98 | +// Signed |
| 99 | +static_assert(std::__libcpp_integer<signed char>); |
| 100 | +static_assert(std::__libcpp_integer<short int>); |
| 101 | +static_assert(std::__libcpp_integer<int>); |
| 102 | +static_assert(std::__libcpp_integer<long int>); |
| 103 | +static_assert(std::__libcpp_integer<long long int>); |
| 104 | +static_assert(std::__libcpp_integer<short int>); |
| 105 | +#ifndef _LIBCPP_HAS_NO_INT128 |
| 106 | +static_assert(std::__libcpp_integer<__int128_t>); |
| 107 | +#endif |
| 108 | +// Non-integer |
| 109 | +static_assert(!std::__libcpp_integer<bool>); |
| 110 | +static_assert(!std::__libcpp_integer<char8_t>); |
| 111 | +static_assert(!std::__libcpp_integer<char16_t>); |
| 112 | +static_assert(!std::__libcpp_integer<char32_t>); |
| 113 | +static_assert(!std::__libcpp_integer<float>); |
| 114 | +static_assert(!std::__libcpp_integer<double>); |
| 115 | +static_assert(!std::__libcpp_integer<long double>); |
| 116 | +static_assert(!std::__libcpp_integer<void>); |
| 117 | +static_assert(!std::__libcpp_integer<SomeObject>); |
0 commit comments