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