1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // concept floating_point = // see below
15 #include <type_traits>
17 #include "arithmetic.h"
20 constexpr 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
);
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
&>);
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
&&>);
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
*>);
41 static_assert(!std::floating_point
<T (*)()>);
42 static_assert(!std::floating_point
<T (&)()>);
43 static_assert(!std::floating_point
<T (&&)()>);
48 // floating-point types
49 static_assert(CheckFloatingPointQualifiers
<float>());
50 static_assert(CheckFloatingPointQualifiers
<double>());
51 static_assert(CheckFloatingPointQualifiers
<long double>());
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>);
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::*)()>());