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
19template <typename T>
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
49static_assert(CheckFloatingPointQualifiers<float>());
50static_assert(CheckFloatingPointQualifiers<double>());
51static_assert(CheckFloatingPointQualifiers<long double>());
52
53// types that aren't floating-point
54static_assert(!CheckFloatingPointQualifiers<signed char>());
55static_assert(!CheckFloatingPointQualifiers<unsigned char>());
56static_assert(!CheckFloatingPointQualifiers<short>());
57static_assert(!CheckFloatingPointQualifiers<unsigned short>());
58static_assert(!CheckFloatingPointQualifiers<int>());
59static_assert(!CheckFloatingPointQualifiers<unsigned int>());
60static_assert(!CheckFloatingPointQualifiers<long>());
61static_assert(!CheckFloatingPointQualifiers<unsigned long>());
62static_assert(!CheckFloatingPointQualifiers<long long>());
63static_assert(!CheckFloatingPointQualifiers<unsigned long long>());
64static_assert(!CheckFloatingPointQualifiers<wchar_t>());
65static_assert(!CheckFloatingPointQualifiers<bool>());
66static_assert(!CheckFloatingPointQualifiers<char>());
67static_assert(!CheckFloatingPointQualifiers<char8_t>());
68static_assert(!CheckFloatingPointQualifiers<char16_t>());
69static_assert(!CheckFloatingPointQualifiers<char32_t>());
70static_assert(!std::floating_point<void>);
71
72static_assert(!CheckFloatingPointQualifiers<ClassicEnum>());
73static_assert(!CheckFloatingPointQualifiers<ScopedEnum>());
74static_assert(!CheckFloatingPointQualifiers<EmptyStruct>());
75static_assert(!CheckFloatingPointQualifiers<int EmptyStruct::*>());
76static_assert(!CheckFloatingPointQualifiers<int (EmptyStruct::*)()>());
77

source code of libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/floating_point.compile.pass.cpp