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 floating_point = // see below 14 15 #include <concepts> 16 #include <type_traits> 17 18 #include "arithmetic.h" 19 20 template <typename T> 21 constexpr bool CheckFloatingPointQualifiers() { 22 constexpr bool result = std::floating_point<T>; 23 static_assert(std::floating_point<const T> == result); 24 static_assert(std::floating_point<volatile T> == result); 25 static_assert(std::floating_point<const volatile T> == result); 26 27 static_assert(!std::floating_point<T&>); 28 static_assert(!std::floating_point<const T&>); 29 static_assert(!std::floating_point<volatile T&>); 30 static_assert(!std::floating_point<const volatile T&>); 31 32 static_assert(!std::floating_point<T&&>); 33 static_assert(!std::floating_point<const T&&>); 34 static_assert(!std::floating_point<volatile T&&>); 35 static_assert(!std::floating_point<const volatile T&&>); 36 37 static_assert(!std::floating_point<T*>); 38 static_assert(!std::floating_point<const T*>); 39 static_assert(!std::floating_point<volatile T*>); 40 static_assert(!std::floating_point<const volatile T*>); 41 42 static_assert(!std::floating_point<T (*)()>); 43 static_assert(!std::floating_point<T (&)()>); 44 static_assert(!std::floating_point<T(&&)()>); 45 46 return result; 47 } 48 49 // floating-point types 50 static_assert(CheckFloatingPointQualifiers<float>()); 51 static_assert(CheckFloatingPointQualifiers<double>()); 52 static_assert(CheckFloatingPointQualifiers<long double>()); 53 54 // types that aren't floating-point 55 static_assert(!CheckFloatingPointQualifiers<signed char>()); 56 static_assert(!CheckFloatingPointQualifiers<unsigned char>()); 57 static_assert(!CheckFloatingPointQualifiers<short>()); 58 static_assert(!CheckFloatingPointQualifiers<unsigned short>()); 59 static_assert(!CheckFloatingPointQualifiers<int>()); 60 static_assert(!CheckFloatingPointQualifiers<unsigned int>()); 61 static_assert(!CheckFloatingPointQualifiers<long>()); 62 static_assert(!CheckFloatingPointQualifiers<unsigned long>()); 63 static_assert(!CheckFloatingPointQualifiers<long long>()); 64 static_assert(!CheckFloatingPointQualifiers<unsigned long long>()); 65 static_assert(!CheckFloatingPointQualifiers<wchar_t>()); 66 static_assert(!CheckFloatingPointQualifiers<bool>()); 67 static_assert(!CheckFloatingPointQualifiers<char>()); 68 static_assert(!CheckFloatingPointQualifiers<char8_t>()); 69 static_assert(!CheckFloatingPointQualifiers<char16_t>()); 70 static_assert(!CheckFloatingPointQualifiers<char32_t>()); 71 static_assert(!std::floating_point<void>); 72 73 static_assert(!CheckFloatingPointQualifiers<ClassicEnum>()); 74 static_assert(!CheckFloatingPointQualifiers<ScopedEnum>()); 75 static_assert(!CheckFloatingPointQualifiers<EmptyStruct>()); 76 static_assert(!CheckFloatingPointQualifiers<int EmptyStruct::*>()); 77 static_assert(!CheckFloatingPointQualifiers<int (EmptyStruct::*)()>()); 78 79 int main(int, char**) { return 0; } 80