diff --git a/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp rename from libcxx/test/std/concepts/callable/invocable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp --- a/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp @@ -18,15 +18,17 @@ #include #include -#include "functions.h" +#include "../functions.h" +// clang-format off template -requires std::invocable constexpr void -ModelsInvocable(F, Args&&...) noexcept{}; +requires std::invocable +constexpr void ModelsInvocable(F, Args&&...) noexcept{} template -requires(!std::invocable) constexpr - void NotInvocable(F, Args&&...) noexcept {} +requires(!std::invocable) +constexpr void NotInvocable(F, Args&&...) noexcept {} +// clang-format on static_assert(!std::invocable); static_assert(!std::invocable); diff --git a/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp rename from libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp --- a/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp @@ -17,7 +17,7 @@ #include #include -#include "functions.h" +#include "../functions.h" template requires std::invocable constexpr void diff --git a/libcxx/test/std/concepts/callable/functions.h b/libcxx/test/std/concepts/concepts.callable/functions.h rename from libcxx/test/std/concepts/callable/functions.h rename to libcxx/test/std/concepts/concepts.callable/functions.h diff --git a/libcxx/test/std/concepts/comparison/concepts.equalitycomparable/equality_comparable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp rename from libcxx/test/std/concepts/comparison/concepts.equalitycomparable/equality_comparable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp diff --git a/libcxx/test/std/concepts/comparison/concepts.equalitycomparable/equality_comparable_with.compile.pass.cpp b/libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp rename from libcxx/test/std/concepts/comparison/concepts.equalitycomparable/equality_comparable_with.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp diff --git a/libcxx/test/std/concepts/comparison/types.h b/libcxx/test/std/concepts/concepts.compare/types.h rename from libcxx/test/std/concepts/comparison/types.h rename to libcxx/test/std/concepts/concepts.compare/types.h diff --git a/libcxx/test/std/concepts/lang/assignable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp rename from libcxx/test/std/concepts/lang/assignable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp diff --git a/libcxx/test/std/concepts/lang/common.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp rename from libcxx/test/std/concepts/lang/common.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp diff --git a/libcxx/test/std/concepts/lang/commonreference.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp rename from libcxx/test/std/concepts/lang/commonreference.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp diff --git a/libcxx/test/std/concepts/concept.constructible/constructible_from.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp rename from libcxx/test/std/concepts/concept.constructible/constructible_from.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp --- a/libcxx/test/std/concepts/concept.constructible/constructible_from.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp @@ -149,3 +149,5 @@ test, int>(); test, int, int>(); } + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/concepts/lang/convertible.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.convertible/convertible_to.pass.cpp rename from libcxx/test/std/concepts/lang/convertible.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.convertible/convertible_to.pass.cpp diff --git a/libcxx/test/std/concepts/lang/copyconstructible.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.copyconstructible/copy_constructible.compile.pass.cpp rename from libcxx/test/std/concepts/lang/copyconstructible.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.copyconstructible/copy_constructible.compile.pass.cpp diff --git a/libcxx/test/std/concepts/concept.default.init/default_initializable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp rename from libcxx/test/std/concepts/concept.default.init/default_initializable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp diff --git a/libcxx/test/std/concepts/concept.default.init/default_initializable.verify.cpp b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.verify.cpp rename from libcxx/test/std/concepts/concept.default.init/default_initializable.verify.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.verify.cpp diff --git a/libcxx/test/std/concepts/lang/derived.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.derived/derived_from.pass.cpp rename from libcxx/test/std/concepts/lang/derived.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.derived/derived_from.pass.cpp diff --git a/libcxx/test/std/concepts/concept.destructible/destructible.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.destructible/destructible.compile.pass.cpp rename from libcxx/test/std/concepts/concept.destructible/destructible.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.destructible/destructible.compile.pass.cpp diff --git a/libcxx/test/std/concepts/lang/moveconstructible.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.moveconstructible/move_constructible.compile.pass.cpp rename from libcxx/test/std/concepts/lang/moveconstructible.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.moveconstructible/move_constructible.compile.pass.cpp diff --git a/libcxx/test/std/concepts/lang/same_as.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.same/same_as.pass.cpp rename from libcxx/test/std/concepts/lang/same_as.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.same/same_as.pass.cpp diff --git a/libcxx/test/std/concepts/lang/swappable.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp rename from libcxx/test/std/concepts/lang/swappable.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp diff --git a/libcxx/test/std/concepts/lang/swappable_with.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable_with.compile.pass.cpp rename from libcxx/test/std/concepts/lang/swappable_with.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable_with.compile.pass.cpp diff --git a/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h new file mode 100644 --- /dev/null +++ b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_ +#define LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_ + +#include + +// This overload should never be called. It exists solely to force subsumption. +template +[[nodiscard]] constexpr bool CheckSubsumption(I) { + return false; +} + +// clang-format off +template +requires std::signed_integral && (!std::unsigned_integral) +[[nodiscard]] constexpr bool CheckSubsumption(I) { + return std::is_signed_v; +} + +template +requires std::unsigned_integral && (!std::signed_integral) +[[nodiscard]] constexpr bool CheckSubsumption(I) { + return std::is_unsigned_v; +} +// clang-format on + +enum ClassicEnum { a, b, c }; +enum class ScopedEnum { x, y, z }; +struct EmptyStruct {}; + +#endif // LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_ diff --git a/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/floating_point.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/floating_point.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/floating_point.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts + +// template +// concept floating_point = // see below + +#include +#include + +#include "arithmetic.h" + +template +constexpr bool CheckFloatingPointQualifiers() { + constexpr bool result = std::floating_point; + static_assert(std::floating_point == result); + static_assert(std::floating_point == result); + static_assert(std::floating_point == result); + + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + + static_assert(!std::floating_point); + static_assert(!std::floating_point); + static_assert(!std::floating_point); + + return result; +} + +// floating-point types +static_assert(CheckFloatingPointQualifiers()); +static_assert(CheckFloatingPointQualifiers()); +static_assert(CheckFloatingPointQualifiers()); + +// types that aren't floating-point +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!std::floating_point); + +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); +static_assert(!CheckFloatingPointQualifiers()); + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/integral.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/integral.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/integral.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts + +// template +// concept integral = // see below + +#include +#include + +#include "arithmetic.h" + +template +constexpr bool CheckIntegralQualifiers() { + constexpr bool result = std::integral; + static_assert(std::integral == result); + static_assert(std::integral == result); + static_assert(std::integral == result); + + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + + static_assert(!std::integral); + static_assert(!std::integral); + static_assert(!std::integral); + + return result; +} + +// standard signed and unsigned integers +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); + +// extended integers +#ifndef _LIBCPP_HAS_NO_INT128 +static_assert(CheckIntegralQualifiers<__int128_t>()); +static_assert(CheckIntegralQualifiers<__uint128_t>()); +#endif + +// bool and char types are also integral +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); +static_assert(CheckIntegralQualifiers()); + +// types that aren't integral +static_assert(!std::integral); +static_assert(!CheckIntegralQualifiers()); +static_assert(!CheckIntegralQualifiers()); +static_assert(!CheckIntegralQualifiers()); + +static_assert(!CheckIntegralQualifiers()); + +static_assert(!CheckIntegralQualifiers()); + +static_assert(!CheckIntegralQualifiers()); +static_assert(!CheckIntegralQualifiers()); +static_assert(!CheckIntegralQualifiers()); + +static_assert(CheckSubsumption(0)); +static_assert(CheckSubsumption(0U)); + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/signed_integral.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/signed_integral.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/signed_integral.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts + +// template +// concept signed_integral = // see below + +#include +#include + +#include "arithmetic.h" + +template +constexpr bool CheckSignedIntegralQualifiers() { + constexpr bool result = std::signed_integral; + static_assert(std::signed_integral == result); + static_assert(std::signed_integral == result); + static_assert(std::signed_integral == result); + + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + static_assert(!std::signed_integral); + + return result; +} + +// standard signed integers +static_assert(CheckSignedIntegralQualifiers()); +static_assert(CheckSignedIntegralQualifiers()); +static_assert(CheckSignedIntegralQualifiers()); +static_assert(CheckSignedIntegralQualifiers()); +static_assert(CheckSignedIntegralQualifiers()); + +// bool and character *may* be signed +static_assert(CheckSignedIntegralQualifiers() == + std::is_signed_v); +static_assert(CheckSignedIntegralQualifiers() == std::is_signed_v); +static_assert(CheckSignedIntegralQualifiers() == std::is_signed_v); +static_assert(CheckSignedIntegralQualifiers() == + std::is_signed_v); +static_assert(CheckSignedIntegralQualifiers() == + std::is_signed_v); +static_assert(CheckSignedIntegralQualifiers() == + std::is_signed_v); + +// integers that aren't signed integrals +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); + +// extended integers +#ifndef _LIBCPP_HAS_NO_INT128 +static_assert(CheckSignedIntegralQualifiers<__int128_t>()); +static_assert(!CheckSignedIntegralQualifiers<__uint128_t>()); +#endif + +// types that aren't even integers shouldn't be signed integers! +static_assert(!std::signed_integral); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); + +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); +static_assert(!CheckSignedIntegralQualifiers()); + +static_assert(CheckSubsumption(0)); +static_assert(CheckSubsumption(0U)); + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/unsigned_integral.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/unsigned_integral.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/unsigned_integral.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts + +// template +// concept unsigned_integral = // see below + +#include +#include + +#include "arithmetic.h" + +template +constexpr bool CheckUnsignedIntegralQualifiers() { + constexpr bool result = std::unsigned_integral; + static_assert(std::unsigned_integral == result); + static_assert(std::unsigned_integral == result); + static_assert(std::unsigned_integral == result); + + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + static_assert(!std::unsigned_integral); + + return result; +} + +// standard unsigned types +static_assert(CheckUnsignedIntegralQualifiers()); +static_assert(CheckUnsignedIntegralQualifiers()); +static_assert(CheckUnsignedIntegralQualifiers()); +static_assert(CheckUnsignedIntegralQualifiers()); +static_assert(CheckUnsignedIntegralQualifiers()); + +// Whether bool and character types are signed or unsigned is impl-defined +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); +static_assert(CheckUnsignedIntegralQualifiers() == + !std::is_signed_v); + +// extended integers +#ifndef _LIBCPP_HAS_NO_INT128 +static_assert(CheckUnsignedIntegralQualifiers<__uint128_t>()); +static_assert(!CheckUnsignedIntegralQualifiers<__int128_t>()); +#endif + +// integer types that aren't unsigned integrals +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); + +static_assert(!std::unsigned_integral); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); + +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); +static_assert(!CheckUnsignedIntegralQualifiers()); + +static_assert(CheckSubsumption(0)); +static_assert(CheckSubsumption(0U)); + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/concepts/object/copyable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/copyable.compile.pass.cpp rename from libcxx/test/std/concepts/object/copyable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.object/copyable.compile.pass.cpp diff --git a/libcxx/test/std/concepts/object/movable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp rename from libcxx/test/std/concepts/object/movable.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp diff --git a/libcxx/test/std/concepts/object/regular.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/regular.compile.pass.cpp rename from libcxx/test/std/concepts/object/regular.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.object/regular.compile.pass.cpp diff --git a/libcxx/test/std/concepts/object/semiregular.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/semiregular.compile.pass.cpp rename from libcxx/test/std/concepts/object/semiregular.compile.pass.cpp rename to libcxx/test/std/concepts/concepts.object/semiregular.compile.pass.cpp diff --git a/libcxx/test/std/concepts/lang/arithmetic.pass.cpp b/libcxx/test/std/concepts/lang/arithmetic.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/concepts/lang/arithmetic.pass.cpp +++ /dev/null @@ -1,346 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 -// UNSUPPORTED: libcpp-no-concepts - -// template -// concept integral = // see below - -// template -// concept signed_integral = // see below - -// template -// concept unsigned_integral = // see below - -// template -// concept floating_point = // see below - -#include -#include - -namespace { -template -constexpr bool CheckIntegralQualifiers() { - constexpr bool result = std::integral; - static_assert(std::integral == result); - static_assert(std::integral == result); - static_assert(std::integral == result); - - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - - static_assert(!std::integral); - static_assert(!std::integral); - static_assert(!std::integral); - - return result; -} - -enum ClassicEnum { a, b, c }; -enum class ScopedEnum { x, y, z }; -struct EmptyStruct {}; - -constexpr void CheckIntegral() { - // standard signed and unsigned integers - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - - // extended integers -#ifndef _LIBCPP_HAS_NO_INT128 - static_assert(CheckIntegralQualifiers<__int128_t>()); - static_assert(CheckIntegralQualifiers<__uint128_t>()); -#endif - - // bool and char types are also integral - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - static_assert(CheckIntegralQualifiers()); - - // types that aren't integral - static_assert(!std::integral); - static_assert(!CheckIntegralQualifiers()); - static_assert(!CheckIntegralQualifiers()); - static_assert(!CheckIntegralQualifiers()); - - static_assert(!CheckIntegralQualifiers()); - - static_assert(!CheckIntegralQualifiers()); - - static_assert(!CheckIntegralQualifiers()); - static_assert(!CheckIntegralQualifiers()); - static_assert(!CheckIntegralQualifiers()); -} - -template -constexpr bool CheckSignedIntegralQualifiers() { - constexpr bool result = std::signed_integral; - static_assert(std::signed_integral == result); - static_assert(std::signed_integral == result); - static_assert(std::signed_integral == result); - - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - static_assert(!std::signed_integral); - - return result; -} - -constexpr void CheckSignedIntegral() { - // standard signed integers - static_assert(CheckSignedIntegralQualifiers()); - static_assert(CheckSignedIntegralQualifiers()); - static_assert(CheckSignedIntegralQualifiers()); - static_assert(CheckSignedIntegralQualifiers()); - static_assert(CheckSignedIntegralQualifiers()); - - // bool and character *may* be signed - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - static_assert(CheckSignedIntegralQualifiers() == - std::is_signed_v); - - // integers that aren't signed integrals - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - - // extended integers -#ifndef _LIBCPP_HAS_NO_INT128 - static_assert(CheckSignedIntegralQualifiers<__int128_t>()); - static_assert(!CheckSignedIntegralQualifiers<__uint128_t>()); -#endif - - // types that aren't even integers shouldn't be signed integers! - static_assert(!std::signed_integral); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); - static_assert(!CheckSignedIntegralQualifiers()); -} - -template -constexpr bool CheckUnsignedIntegralQualifiers() { - constexpr bool result = std::unsigned_integral; - static_assert(std::unsigned_integral == result); - static_assert(std::unsigned_integral == result); - static_assert(std::unsigned_integral == result); - - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - static_assert(!std::unsigned_integral); - - return result; -} - -constexpr void CheckUnsignedIntegral() { - // standard unsigned types - static_assert(CheckUnsignedIntegralQualifiers()); - static_assert(CheckUnsignedIntegralQualifiers()); - static_assert(CheckUnsignedIntegralQualifiers()); - static_assert(CheckUnsignedIntegralQualifiers()); - static_assert(CheckUnsignedIntegralQualifiers()); - - // Whether bool and character types are signed or unsigned is impl-defined - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - static_assert(CheckUnsignedIntegralQualifiers() == - !std::is_signed_v); - - // extended integers -#ifndef _LIBCPP_HAS_NO_INT128 - static_assert(CheckUnsignedIntegralQualifiers<__uint128_t>()); - static_assert(!CheckUnsignedIntegralQualifiers<__int128_t>()); -#endif - - // integer types that aren't unsigned integrals - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - - static_assert(!std::unsigned_integral); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); - static_assert(!CheckUnsignedIntegralQualifiers()); -} - -// This overload should never be called. It exists solely to force subsumption. -template -[[nodiscard]] constexpr bool CheckSubsumption(I) { - return false; -} - -// clang-format off -template -requires std::signed_integral && (!std::unsigned_integral) -[[nodiscard]] constexpr bool CheckSubsumption(I) { - return std::is_signed_v; -} - -template -requires std::unsigned_integral && (!std::signed_integral) -[[nodiscard]] constexpr bool CheckSubsumption(I) { - return std::is_unsigned_v; -} -// clang-format on - -template -constexpr bool CheckFloatingPointQualifiers() { - constexpr bool result = std::floating_point; - static_assert(std::floating_point == result); - static_assert(std::floating_point == result); - static_assert(std::floating_point == result); - - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - - static_assert(!std::floating_point); - static_assert(!std::floating_point); - static_assert(!std::floating_point); - - return result; -} - -constexpr void CheckFloatingPoint() { - // floating-point types - static_assert(CheckFloatingPointQualifiers()); - static_assert(CheckFloatingPointQualifiers()); - static_assert(CheckFloatingPointQualifiers()); - - // types that aren't floating-point - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!std::floating_point); - - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); - static_assert(!CheckFloatingPointQualifiers()); -} -} // namespace - -int main(int, char**) { - CheckIntegral(); - CheckSignedIntegral(); - CheckUnsignedIntegral(); - static_assert(CheckSubsumption(0)); - static_assert(CheckSubsumption(0U)); - CheckFloatingPoint(); - return 0; -}