From 2b4f450e4d5f3908d775edd34dd6722215d5cd7b Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Tue, 13 Sep 2022 21:02:27 +0200 Subject: [PATCH] Implement concept emulation for C++14 / C++17 This also ports all the standard concepts from libc++ preserving the new modular organization. --- .../equivalence_relation.compile.pass.cpp | 63 + ...ence_relation.subsumption.compile.pass.cpp | 81 ++ .../invocable.compile.pass.cpp | 416 +++++++ .../predicate.compile.pass.cpp | 73 ++ .../predicate.subsumption.compile.pass.cpp | 31 + .../regular_invocable.compile.pass.cpp | 474 +++++++ .../relation.compile.pass.cpp | 61 + .../relation.subsumption.compile.pass.cpp | 64 + .../strict_weak_order.compile.pass.cpp | 62 + ...ct_weak_order.subsumption.compile.pass.cpp | 80 ++ .../equality_comparable.compile.pass.cpp | 135 ++ .../equality_comparable_with.compile.pass.cpp | 1085 ++++++++++++++++ .../totally_ordered.pass.cpp | 158 +++ .../totally_ordered_with.pass.cpp | 1109 +++++++++++++++++ .../assignable_from.compile.pass.cpp | 114 ++ .../common_with.compile.pass.cpp | 1021 +++++++++++++++ .../common_reference.compile.pass.cpp | 376 ++++++ .../constructible_from.compile.pass.cpp | 142 +++ .../convertible_to.pass.cpp | 437 +++++++ .../copy_constructible.compile.pass.cpp | 179 +++ .../default_initializable.compile.pass.cpp | 196 +++ .../default_initializable.verify.cpp | 81 ++ .../concept.derived/derived_from.pass.cpp | 519 ++++++++ .../destructible.compile.pass.cpp | 80 ++ .../move_constructible.compile.pass.cpp | 83 ++ .../concept.same/same_as.pass.cpp | 305 +++++ .../concept.swappable/swappable.pass.cpp | 263 ++++ .../swappable_with.compile.pass.cpp | 797 ++++++++++++ .../concepts.arithmetic/arithmetic.h | 40 + .../floating_point.pass.cpp | 84 ++ .../concepts.arithmetic/integral.pass.cpp | 100 ++ .../signed_integral.pass.cpp | 104 ++ .../unsigned_integral.pass.cpp | 105 ++ .../concepts.object/copyable.compile.pass.cpp | 99 ++ .../concepts.object/movable.compile.pass.cpp | 122 ++ .../concepts.object/regular.compile.pass.cpp | 144 +++ .../semiregular.compile.pass.cpp | 108 ++ .upstream-tests/test/support/compare_types.h | 399 ++++++ .../support/type_classification/copyable.h | 78 ++ .../support/type_classification/movable.h | 159 +++ .../type_classification/moveconstructible.h | 75 ++ .../support/type_classification/semiregular.h | 30 + .../support/type_classification/swappable.h | 307 +++++ include/cuda/std/concepts | 55 + include/cuda/std/detail/__concepts | 278 +++++ .../libcxx/include/__concepts/_One_of.h | 35 + .../libcxx/include/__concepts/arithmetic.h | 53 + .../libcxx/include/__concepts/assignable.h | 60 + .../include/__concepts/boolean_testable.h | 62 + .../libcxx/include/__concepts/class_or_enum.h | 38 + .../__concepts/common_reference_with.h | 58 + .../libcxx/include/__concepts/common_with.h | 93 ++ .../libcxx/include/__concepts/constructible.h | 98 ++ .../include/__concepts/convertible_to.h | 52 + .../libcxx/include/__concepts/copyable.h | 49 + .../libcxx/include/__concepts/derived_from.h | 41 + .../libcxx/include/__concepts/destructible.h | 35 + .../include/__concepts/different_from.h | 36 + .../include/__concepts/equality_comparable.h | 111 ++ .../libcxx/include/__concepts/invocable.h | 58 + .../libcxx/include/__concepts/movable.h | 59 + .../libcxx/include/__concepts/predicate.h | 51 + .../libcxx/include/__concepts/regular.h | 39 + .../libcxx/include/__concepts/relation.h | 49 + .../libcxx/include/__concepts/same_as.h | 46 + .../libcxx/include/__concepts/semiregular.h | 39 + .../libcxx/include/__concepts/swappable.h | 225 ++++ .../include/__concepts/totally_ordered.h | 100 ++ .../include/__type_traits/common_reference.h | 188 +++ .../libcxx/include/__type_traits/copy_cv.h | 55 + .../libcxx/include/__type_traits/copy_cvref.h | 49 + .../std/detail/libcxx/include/type_traits | 6 + .../cuda/std/detail/libcxx/include/utility | 2 +- 73 files changed, 12558 insertions(+), 1 deletion(-) create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.subsumption.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.subsumption.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.subsumption.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.subsumption.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered_with.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.convertible/convertible_to.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.copyconstructible/copy_constructible.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.default.init/default_initializable.verify.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.derived/derived_from.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.destructible/destructible.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.moveconstructible/move_constructible.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.same/same_as.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concept.swappable/swappable_with.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concepts.arithmetic/floating_point.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concepts.arithmetic/integral.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concepts.arithmetic/signed_integral.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.lang/concepts.arithmetic/unsigned_integral.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.object/copyable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.object/movable.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.object/regular.compile.pass.cpp create mode 100644 .upstream-tests/test/std/concepts/concepts.object/semiregular.compile.pass.cpp create mode 100644 .upstream-tests/test/support/compare_types.h create mode 100644 .upstream-tests/test/support/type_classification/copyable.h create mode 100644 .upstream-tests/test/support/type_classification/movable.h create mode 100644 .upstream-tests/test/support/type_classification/moveconstructible.h create mode 100644 .upstream-tests/test/support/type_classification/semiregular.h create mode 100644 .upstream-tests/test/support/type_classification/swappable.h create mode 100644 include/cuda/std/concepts create mode 100644 include/cuda/std/detail/__concepts create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/_One_of.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/arithmetic.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/assignable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/boolean_testable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/class_or_enum.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/common_reference_with.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/common_with.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/constructible.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/convertible_to.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/copyable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/derived_from.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/destructible.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/different_from.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/equality_comparable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/invocable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/movable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/predicate.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/regular.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/relation.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/same_as.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/semiregular.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/swappable.h create mode 100644 include/cuda/std/detail/libcxx/include/__concepts/totally_ordered.h create mode 100644 include/cuda/std/detail/libcxx/include/__type_traits/common_reference.h create mode 100644 include/cuda/std/detail/libcxx/include/__type_traits/copy_cv.h create mode 100644 include/cuda/std/detail/libcxx/include/__type_traits/copy_cvref.h diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.compile.pass.cpp new file mode 100644 index 0000000000..74acc719de --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.compile.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept equivalence_relation; + +#include + +using cuda::std::equivalence_relation; + +static_assert(equivalence_relation); +static_assert(equivalence_relation); +static_assert(equivalence_relation); + +static_assert(!equivalence_relation); +static_assert(!equivalence_relation); +static_assert(!equivalence_relation); + +static_assert( + !equivalence_relation); +static_assert(!equivalence_relation); + +struct S1 {}; +static_assert(cuda::std::relation); +static_assert(cuda::std::relation); + +struct S2 {}; + +struct P1 { + bool operator()(S1, S1) const; +}; +static_assert(equivalence_relation); + +struct P2 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; +}; +static_assert(!equivalence_relation); + +struct P3 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; +}; +static_assert(!equivalence_relation); + +struct P4 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; +static_assert(equivalence_relation); + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.subsumption.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.subsumption.compile.pass.cpp new file mode 100644 index 0000000000..819894e990 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.equiv/equivalence_relation.subsumption.compile.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// template +// concept equivalence_relation; + +#include + +struct S1 {}; +struct S2 {}; + +struct R { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; + +// clang-format off +template +requires cuda::std::relation +constexpr bool check_equivalence_relation_subsumes_relation() { + return false; +} + +template +requires cuda::std::equivalence_relation && true +constexpr bool check_equivalence_relation_subsumes_relation() { + return true; +} +// clang-format on + +static_assert(check_equivalence_relation_subsumes_relation()); +static_assert(check_equivalence_relation_subsumes_relation()); +static_assert(check_equivalence_relation_subsumes_relation()); +static_assert(check_equivalence_relation_subsumes_relation()); + +// clang-format off +template +requires cuda::std::relation && true +constexpr bool check_relation_subsumes_equivalence_relation() { + return true; +} + +template +requires cuda::std::equivalence_relation +constexpr bool check_relation_subsumes_equivalence_relation() { + return false; +} +// clang-format on + +static_assert(check_relation_subsumes_equivalence_relation()); +static_assert(check_relation_subsumes_equivalence_relation()); +static_assert(check_relation_subsumes_equivalence_relation()); +static_assert(check_relation_subsumes_equivalence_relation()); + +// clang-format off +template +requires cuda::std::equivalence_relation && cuda::std::equivalence_relation +constexpr bool check_equivalence_relation_subsumes_itself() { + return false; +} + +template +requires cuda::std::equivalence_relation +constexpr bool check_equivalence_relation_subsumes_itself() { + return true; +} +// clang-format on + +static_assert( + check_equivalence_relation_subsumes_itself()); +static_assert(check_equivalence_relation_subsumes_itself()); diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp new file mode 100644 index 0000000000..9e330d08cc --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp @@ -0,0 +1,416 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept invocable; + +#include +#include +#include +#include + +using cuda::std::invocable; + +template +constexpr bool check_invocable() { + constexpr bool result = invocable; + static_assert(invocable == result); + static_assert(invocable == result); + static_assert(invocable == result); + static_assert(invocable == result); + static_assert(invocable == result); + + return result; +} + +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); + +struct S; +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); + +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +namespace function_objects { +struct function_object { + void operator()(); +}; +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +struct const_function_object { + void operator()(int) const; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); + +struct volatile_function_object { + void operator()(int, int) volatile; +}; +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert( + !invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert( + !invocable); + +struct cv_function_object { + void operator()(int[]) const volatile; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); + +struct lvalue_function_object { + void operator()() &; +}; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +struct lvalue_const_function_object { + void operator()(int) const&; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert( + !invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert( + !invocable); + +struct lvalue_volatile_function_object { + void operator()(int, int) volatile&; +}; +static_assert(!invocable); +static_assert(!invocable); +static_assert( + !invocable); +static_assert( + !invocable); +static_assert(invocable); +static_assert( + !invocable); +static_assert( + invocable); +static_assert( + !invocable); + +struct lvalue_cv_function_object { + void operator()(int[]) const volatile&; +}; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +// +struct rvalue_function_object { + void operator()() &&; +}; +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +struct rvalue_const_function_object { + void operator()(int) const&&; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert( + !invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert( + !invocable); + +struct rvalue_volatile_function_object { + void operator()(int, int) volatile&&; +}; +static_assert(invocable); +static_assert(!invocable); +static_assert( + invocable); +static_assert( + !invocable); +static_assert(!invocable); +static_assert( + !invocable); +static_assert( + !invocable); +static_assert( + !invocable); + +struct rvalue_cv_function_object { + void operator()(int[]) const volatile&&; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +struct multiple_overloads { + struct A {}; + struct B { B(int); }; + struct AB : A, B {}; + struct O {}; + void operator()(A) const; + void operator()(B) const; +}; +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +} // namespace function_objects + +namespace pointer_to_member_functions { + template + constexpr bool check_member_is_invocable() + { + constexpr bool result = invocable; + using uncv_t = cuda::std::remove_cvref_t; + static_assert(invocable == result); + static_assert(invocable, Args...> == result); + static_assert(!invocable); + static_assert(!invocable); + static_assert(!invocable); + static_assert(!invocable); + struct S2 {}; + static_assert(!invocable); + return result; + } + +static_assert(check_member_is_invocable()); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); + +static_assert(check_member_is_invocable()); +static_assert(!check_member_is_invocable()); +using unqualified = void (S::*)(); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +static_assert(check_member_is_invocable()); +using const_qualified = void (S::*)() const; +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); + +static_assert( + check_member_is_invocable()); +using volatile_qualified = void (S::*)() volatile; +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); + +static_assert(check_member_is_invocable()); +using cv_qualified = void (S::*)() const volatile; +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); + +static_assert(check_member_is_invocable()); +using lvalue_qualified = void (S::*)() &; +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +#if TEST_STD_VER > 17 +static_assert(check_member_is_invocable()); +#endif // TEST_STD_VER > 17 +using lvalue_const_qualified = void (S::*)() const&; +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +#if TEST_STD_VER > 17 +static_assert(invocable); +static_assert(invocable); +#endif // TEST_STD_VER > 17 +static_assert(!invocable); +static_assert(!invocable); + +static_assert(check_member_is_invocable()); +using lvalue_volatile_qualified = void (S::*)() volatile&; +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +static_assert(check_member_is_invocable()); +using lvalue_cv_qualified = void (S::*)() const volatile&; +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +using rvalue_unqualified = void (S::*)() &&; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); + +using rvalue_const_unqualified = void (S::*)() const&&; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(!invocable); + +using rvalue_volatile_unqualified = void (S::*)() volatile&&; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(!invocable); + +using rvalue_cv_unqualified = void (S::*)() const volatile&&; +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(!invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +static_assert(invocable); +} // namespace pointer_to_member_functions + +// Check the concept with closure types +template +constexpr bool is_invocable(F, Args&&...) { + return invocable; +} + +#if TEST_STD_VER > 14 +static_assert(is_invocable([] {})); +static_assert(is_invocable([](int) {}, 0)); +static_assert(is_invocable([](int) {}, 0L)); +static_assert(!is_invocable([](int) {}, nullptr)); +int i = 0; +static_assert(is_invocable([](int&) {}, i)); +#endif // TEST_STD_VER > 14 + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.compile.pass.cpp new file mode 100644 index 0000000000..ecd9f9eee8 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.compile.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept predicate; + +#include +#include + +using cuda::std::predicate; + +static_assert(predicate); +static_assert(predicate); +static_assert(predicate); + +static_assert(!predicate); +static_assert(!predicate); +static_assert(!predicate); + +struct S {}; + +static_assert(!predicate); +static_assert(!predicate); +static_assert(predicate); +static_assert(predicate); +static_assert(predicate); +static_assert(!predicate); +static_assert(!predicate); + +static_assert(!predicate); +static_assert(!predicate); +static_assert(!predicate); +static_assert(!predicate); +static_assert(predicate); + +struct Predicate { + bool operator()(int, double, char); +}; +static_assert(predicate); +static_assert(predicate); +static_assert(!predicate); +static_assert(!predicate); + +#if TEST_STD_VER > 17 +constexpr bool check_lambda(auto) { return false; } + +constexpr bool check_lambda(predicate auto) { return true; } +#endif // TEST_STD_VER > 17 + +#if TEST_STD_VER > 14 +static_assert(check_lambda([] { return std::true_type(); })); +static_assert(check_lambda([]() -> int* { return nullptr; })); + +struct boolean { + operator bool() const noexcept; +}; +static_assert(check_lambda([] { return boolean(); })); + +struct explicit_bool { + explicit operator bool() const noexcept; +}; +static_assert(!check_lambda([] { return explicit_bool(); })); +#endif // TEST_STD_VER > 14 + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.subsumption.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.subsumption.compile.pass.cpp new file mode 100644 index 0000000000..621013ea6b --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.predicate/predicate.subsumption.compile.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// template +// concept predicate; + +#include + +constexpr bool check_subsumption(cuda::std::regular_invocable auto) { + return false; +} + +// clang-format off +template +requires cuda::std::predicate && true +constexpr bool check_subsumption(F) +{ + return true; +} +// clang-format on + +static_assert(!check_subsumption([] {})); +static_assert(check_subsumption([] { return true; })); diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp new file mode 100644 index 0000000000..40d0d0c6b6 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp @@ -0,0 +1,474 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept regular_invocable; + +#include +#include +#include +#include + +using cuda::std::regular_invocable; + +template +constexpr bool check_invocable() { + constexpr bool result = regular_invocable; + static_assert(regular_invocable == result); + static_assert(regular_invocable == result); + static_assert(regular_invocable == + result); + static_assert(regular_invocable == result); + static_assert(regular_invocable == + result); + + return result; +} + +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(check_invocable()); + +struct S; +static_assert(check_invocable()); +static_assert(check_invocable()); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); + +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +namespace function_objects { +struct function_object { + void operator()(); +}; +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +struct const_function_object { + void operator()(int) const; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); + +struct volatile_function_object { + void operator()(int, int) volatile; +}; +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert( + regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert( + regular_invocable); +static_assert(!regular_invocable); + +struct cv_function_object { + void operator()(int[]) const volatile; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); + +struct lvalue_function_object { + void operator()() &; +}; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +struct lvalue_const_function_object { + void operator()(int) const&; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); + +struct lvalue_volatile_function_object { + void operator()(int, int) volatile&; +}; +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable< + lvalue_volatile_function_object const volatile, int, int>); +static_assert( + regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable< + lvalue_volatile_function_object const volatile&, int, int>); + +struct lvalue_cv_function_object { + void operator()(int[]) const volatile&; +}; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + regular_invocable); +static_assert( + regular_invocable); +// +struct rvalue_function_object { + void operator()() &&; +}; +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +struct rvalue_const_function_object { + void operator()(int) const&&; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); + +struct rvalue_volatile_function_object { + void operator()(int, int) volatile&&; +}; +static_assert( + regular_invocable); +static_assert( + !regular_invocable); +static_assert( + regular_invocable); +static_assert(!regular_invocable< + rvalue_volatile_function_object const volatile, int, int>); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable< + rvalue_volatile_function_object const volatile&, int, int>); + +struct rvalue_cv_function_object { + void operator()(int[]) const volatile&&; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); + +struct multiple_overloads { + struct A {}; + struct B { B(int); }; + struct AB : A, B {}; + struct O {}; + void operator()(A) const; + void operator()(B) const; +}; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +} // namespace function_objects + +namespace pointer_to_member_functions { + template + constexpr bool check_member_is_invocable() + { + constexpr bool result = regular_invocable; + using uncv_t = cuda::std::remove_cvref_t; + static_assert(regular_invocable == result); + static_assert(regular_invocable, Args...> == result); + static_assert(!regular_invocable); + static_assert(!regular_invocable); + static_assert(!regular_invocable); + static_assert(!regular_invocable); + struct S2 {}; + static_assert(!regular_invocable); + return result; + } + +static_assert(check_member_is_invocable()); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); + +static_assert(check_member_is_invocable()); +static_assert(!check_member_is_invocable()); +using unqualified = void (S::*)(); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +static_assert(check_member_is_invocable()); +using const_qualified = void (S::*)() const; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +static_assert( + check_member_is_invocable()); +using volatile_qualified = void (S::*)() volatile; +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); + +static_assert(check_member_is_invocable()); +using cv_qualified = void (S::*)() const volatile; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); + +static_assert(check_member_is_invocable()); +using lvalue_qualified = void (S::*)() &; +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +#if TEST_STD_VER > 17 +static_assert(check_member_is_invocable()); +#endif // TEST_STD_VER > 17 +using lvalue_const_qualified = void (S::*)() const&; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +#if TEST_STD_VER > 17 +static_assert(regular_invocable); +static_assert(regular_invocable); +#endif // TEST_STD_VER > 17 +static_assert(!regular_invocable); +static_assert( + !regular_invocable); + +static_assert(check_member_is_invocable()); +using lvalue_volatile_qualified = void (S::*)() volatile&; +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert( + !regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); + +static_assert(check_member_is_invocable()); +using lvalue_cv_qualified = void (S::*)() const volatile&; +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +using rvalue_unqualified = void (S::*)() &&; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); + +using rvalue_const_unqualified = void (S::*)() const&&; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); + +using rvalue_volatile_unqualified = void (S::*)() volatile&&; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(!regular_invocable); +static_assert( + regular_invocable); +static_assert( + !regular_invocable); + +using rvalue_cv_unqualified = void (S::*)() const volatile&&; +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert(!regular_invocable); +static_assert( + !regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert(regular_invocable); +static_assert( + regular_invocable); +} // namespace pointer_to_member_functions + +// Check the concept with closure types (and also check for subsumption) +#if TEST_STD_VER > 17 +template +constexpr bool is_regular_invocable(F, Args&&...) { + return false; +} + +template +requires std::invocable +constexpr bool is_regular_invocable(F, Args&&...) { + return false; +} + +template +requires regular_invocable && true +constexpr bool is_regular_invocable(F, Args&&...) { + return true; +} +#else +template +constexpr bool is_regular_invocable(F, Args&&...) { + return regular_invocable; +} +#endif // TEST_STD_VER > 17 + +#if TEST_STD_VER > 14 +static_assert(is_regular_invocable([] {})); +static_assert(is_regular_invocable([](int) {}, 0)); +static_assert(is_regular_invocable([](int) {}, 0L)); +static_assert(!is_regular_invocable([](int) {}, nullptr)); + +int i = 0; +static_assert(is_regular_invocable([](int&) {}, i)); +#endif // TEST_STD_VER > 14 + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.compile.pass.cpp new file mode 100644 index 0000000000..21886a8fbd --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.compile.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept relation; + +#include + +using cuda::std::relation; + +static_assert(relation); +static_assert(relation); +static_assert(relation); + +static_assert(!relation); +static_assert(!relation); +static_assert(!relation); +static_assert(!relation); +static_assert(!relation); + +struct S1 {}; +static_assert(relation); +static_assert(relation); + +struct S2 {}; + +struct P1 { + bool operator()(S1, S1) const; +}; +static_assert(relation); + +struct P2 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; +}; +static_assert(!relation); + +struct P3 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; +}; +static_assert(!relation); + +struct P4 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; +static_assert(relation); + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.subsumption.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.subsumption.compile.pass.cpp new file mode 100644 index 0000000000..8f0add0e1e --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.relation/relation.subsumption.compile.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// template +// concept relation; + +#include + +struct S1 {}; +struct S2 {}; + +struct R { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; + +// clang-format off +template +requires cuda::std::predicate && cuda::std::predicate && + cuda::std::predicate && cuda::std::predicate +constexpr bool check_relation_subsumes_predicate() { + return false; +} + +template +requires cuda::std::relation && true +constexpr bool check_relation_subsumes_predicate() { + return true; +} +// clang-format on + +static_assert( + check_relation_subsumes_predicate()); +static_assert( + check_relation_subsumes_predicate()); +static_assert(check_relation_subsumes_predicate()); +static_assert(check_relation_subsumes_predicate()); + +// clang-format off +template +requires cuda::std::relation && cuda::std::relation +constexpr bool check_relation_subsumes_itself() { + return false; +} + +template +requires cuda::std::relation +constexpr bool check_relation_subsumes_itself() { + return true; +} +// clang-format on + +static_assert(check_relation_subsumes_itself()); +static_assert(check_relation_subsumes_itself()); diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.compile.pass.cpp new file mode 100644 index 0000000000..afc8c7aed6 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.compile.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept strict_weak_order; + +#include + +using cuda::std::strict_weak_order; + +static_assert(strict_weak_order); +static_assert(strict_weak_order); +static_assert(strict_weak_order); + +static_assert(!strict_weak_order); +static_assert(!strict_weak_order); +static_assert(!strict_weak_order); + +static_assert(!strict_weak_order); +static_assert(!strict_weak_order); + +struct S1 {}; +static_assert(strict_weak_order); +static_assert(strict_weak_order); + +struct S2 {}; + +struct P1 { + bool operator()(S1, S1) const; +}; +static_assert(strict_weak_order); + +struct P2 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; +}; +static_assert(!strict_weak_order); + +struct P3 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; +}; +static_assert(!strict_weak_order); + +struct P4 { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; +static_assert(strict_weak_order); + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.subsumption.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.subsumption.compile.pass.cpp new file mode 100644 index 0000000000..876f85864d --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.callable/concept.strictweakorder/strict_weak_order.subsumption.compile.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// template +// concept strict_weak_order; + +#include + +struct S1 {}; +struct S2 {}; + +struct R { + bool operator()(S1, S1) const; + bool operator()(S1, S2) const; + bool operator()(S2, S1) const; + bool operator()(S2, S2) const; +}; + +// clang-format off +template +requires cuda::std::relation +constexpr bool check_strict_weak_order_subsumes_relation() { + return false; +} + +template +requires cuda::std::strict_weak_order && true +constexpr bool check_strict_weak_order_subsumes_relation() { + return true; +} +// clang-format on + +static_assert(check_strict_weak_order_subsumes_relation()); +static_assert(check_strict_weak_order_subsumes_relation()); +static_assert(check_strict_weak_order_subsumes_relation()); +static_assert(check_strict_weak_order_subsumes_relation()); + +// clang-format off +template +requires cuda::std::relation && true +constexpr bool check_relation_subsumes_strict_weak_order() { + return true; +} + +template +requires cuda::std::strict_weak_order +constexpr bool check_relation_subsumes_strict_weak_order() { + return false; +} +// clang-format on + +static_assert(check_relation_subsumes_strict_weak_order()); +static_assert(check_relation_subsumes_strict_weak_order()); +static_assert(check_relation_subsumes_strict_weak_order()); +static_assert(check_relation_subsumes_strict_weak_order()); + +// clang-format off +template +requires cuda::std::strict_weak_order && cuda::std::strict_weak_order +constexpr bool check_strict_weak_order_subsumes_itself() { + return false; +} + +template +requires cuda::std::strict_weak_order +constexpr bool check_strict_weak_order_subsumes_itself() { + return true; +} +// clang-format on + +static_assert(check_strict_weak_order_subsumes_itself()); +static_assert(check_strict_weak_order_subsumes_itself()); diff --git a/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp new file mode 100644 index 0000000000..08a143ab06 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp @@ -0,0 +1,135 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept equality_comparable = // see below + +#include + +#include + +#include "compare_types.h" + +using cuda::std::equality_comparable; + +namespace fundamentals { +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) +static_assert(equality_comparable); +#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t) +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); + +struct S {}; +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert( + equality_comparable); + +static_assert(!equality_comparable); +} // namespace fundamentals + +namespace standard_types { +static_assert(equality_comparable>); +} // namespace standard_types + +namespace types_fit_for_purpose { +#if TEST_STD_VER > 17 +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +#endif // TEST_STD_VER > 17 + +static_assert(!equality_comparable); +static_assert(!equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); + +static_assert(!equality_comparable); +static_assert(!equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(!equality_comparable); + +#if TEST_STD_VER > 17 +static_assert( + !equality_comparable); +static_assert( + !equality_comparable); +static_assert( + !equality_comparable); +static_assert( + !equality_comparable); +static_assert( + !equality_comparable); +static_assert( + !equality_comparable); +#endif // TEST_STD_VER > 17 + +static_assert(!equality_comparable); +static_assert(!equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +static_assert(equality_comparable); +} // namespace types_fit_for_purpose + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp new file mode 100644 index 0000000000..1cc71bed1b --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp @@ -0,0 +1,1085 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept equality_comparable_with = // see below + +#include + +#include + +#include "test_macros.h" +#include "compare_types.h" + +using cuda::std::equality_comparable_with; +using cuda::std::nullptr_t; + +template +constexpr bool check_equality_comparable_with() { + constexpr bool result = equality_comparable_with; + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + static_assert(equality_comparable_with == result); + return result; +} + +namespace fundamentals { +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); + +struct S {}; +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int, int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int*, int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int*, int (S::*)() const volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int*, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int*, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int*, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int*, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int[5], int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int[5], int (S::*)() const volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int[5], + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int[5], + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int[5], + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int[5], + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (*)(), int (S::*)() volatile noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (*)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (*)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (*)(), + int (S::*)() && noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (*)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (*)(), + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (*)(), + int (S::*)() const volatile&& noexcept > ()); + +#if TEST_STD_VER > 17 +static_assert(check_equality_comparable_with()); +#endif // TEST_STD_VER > 17 +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (&)(), int (S::*)() volatile noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (&)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (&)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (&)(), + int (S::*)() && noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (&)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (&)(), + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (&)(), + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)(), int (S::*)() volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)(), int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)(), + int (S::*)() && noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)(), + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)(), + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() noexcept, int (S::*)() volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() noexcept, int (S::*)() const volatile noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() noexcept, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() noexcept, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const, int (S::*)() volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const, int (S::*)() const volatile noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const noexcept, int (S::*)() volatile noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const noexcept, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() volatile, int (S::*)() const volatile noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() volatile, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() volatile, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() &>()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() & noexcept>()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() const&>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() volatile&>()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() &&>()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() const&&>()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile noexcept, int (S::*)() volatile&&>()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() &, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() &, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &, + int (S::*)() && noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() & noexcept, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() & noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() & noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() & noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() & noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const&, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const&, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + int (S::*)() volatile&, int (S::*)() volatile & noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile&, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile&, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const volatile&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile & noexcept, int (S::*)() &&>()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_equality_comparable_with< + int (S::*)() const volatile & noexcept, int (S::*)() const&&>()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() + const volatile& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() &&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() const&& > ()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() volatile&& > ()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_equality_comparable_with < int (S::*)() && noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() const&& noexcept, + int (S::*)() volatile&& > ()); +static_assert(!check_equality_comparable_with < int (S::*)() const&& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_equality_comparable_with < int (S::*)() const&& noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_equality_comparable_with < int (S::*)() const&& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + int (S::*)() volatile&&, int (S::*)() volatile && noexcept>()); +static_assert(!check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < int (S::*)() volatile&&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + check_equality_comparable_with()); +static_assert(!check_equality_comparable_with < + int (S::*)() volatile&& noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_equality_comparable_with < + int (S::*)() volatile&& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); + +static_assert(!check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + nullptr_t, int (S::*)() const volatile noexcept>()); +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + nullptr_t, int (S::*)() volatile & noexcept>()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + nullptr_t, int (S::*)() const volatile & noexcept>()); +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + nullptr_t, int (S::*)() volatile && noexcept>()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with< + nullptr_t, int (S::*)() const volatile && noexcept>()); + +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() && noexcept >); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() const&& noexcept >); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() volatile&& noexcept >); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() const volatile&& noexcept >); +} // namespace fundamentals + +namespace standard_types { +static_assert(check_equality_comparable_with, + cuda::std::array >()); +static_assert(!check_equality_comparable_with, + cuda::std::array >()); +} // namespace standard_types + +namespace types_fit_for_purpose { +#if TEST_STD_VER > 17 +static_assert( + check_equality_comparable_with()); +static_assert( + check_equality_comparable_with()); +static_assert( + !check_equality_comparable_with()); + +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(!check_equality_comparable_with()); +#endif // TEST_STD_VER > 17 + +static_assert( + check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); +static_assert(check_equality_comparable_with()); + +#if TEST_STD_VER > 17 +static_assert(check_equality_comparable_with()); +static_assert( + cuda::std::common_reference_with); +static_assert( + !check_equality_comparable_with()); + +static_assert(check_equality_comparable_with()); +static_assert( + cuda::std::common_reference_with); +static_assert( + !check_equality_comparable_with()); +#endif // TEST_STD_VER > 17 +} // namespace types_fit_for_purpose + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered.pass.cpp b/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered.pass.cpp new file mode 100644 index 0000000000..d31d43a49f --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered.pass.cpp @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept totally_ordered; + +#include + +#include + +#include "compare_types.h" +#include "test_macros.h" + +using cuda::std::totally_ordered; + +// `models_totally_ordered` checks that `totally_ordered` subsumes +// `std::equality_comparable`. This overload should *never* be called. +#if TEST_STD_VER > 17 +template +constexpr bool models_totally_ordered() noexcept { + return false; +} +#endif // TEST_STD_VER > 17 + +_LIBCUDACXX_TEMPLATE(class T) + (requires cuda::std::totally_ordered) +constexpr bool models_totally_ordered() noexcept { + return true; +} + +namespace fundamentals { +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +#if TEST_STD_VER > 17 && defined(__cpp_char8_t) +static_assert(models_totally_ordered()); +#endif // TEST_STD_VER > 17 && defined(__cpp_char8_t) +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); + +#ifndef TEST_COMPILER_GCC +static_assert(!totally_ordered); +#endif + +struct S {}; +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered < int (S::*)() && noexcept >); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered < int (S::*)() const&& noexcept >); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered < int (S::*)() volatile&& noexcept >); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered < int (S::*)() const volatile&& noexcept >); + +static_assert(!totally_ordered); +} // namespace fundamentals + +namespace standard_types { +static_assert(models_totally_ordered >()); +} // namespace standard_types + +namespace types_fit_for_purpose { +#if TEST_STD_VER > 17 +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(models_totally_ordered()); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +#endif // TEST_STD_VER > 17 + +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); + +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); + +#if TEST_STD_VER > 17 +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert( + !totally_ordered); +static_assert( + !totally_ordered); +static_assert( + !totally_ordered); +static_assert( + !totally_ordered); +#endif // TEST_STD_VER > 17 + +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(!totally_ordered); +static_assert(totally_ordered); +static_assert(totally_ordered); + +#if TEST_STD_VER > 17 +static_assert(totally_ordered); +static_assert(totally_ordered); +static_assert(totally_ordered); +#endif // TEST_STD_VER > 17 +} // namespace types_fit_for_purpose + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered_with.pass.cpp b/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered_with.pass.cpp new file mode 100644 index 0000000000..b2cb94edb6 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.compare/concepts.totallyordered/totally_ordered_with.pass.cpp @@ -0,0 +1,1109 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept totally_ordered_with; + +#include + +#include + +#include "compare_types.h" +#include "test_macros.h" + +using cuda::std::totally_ordered_with; +using cuda::std::equality_comparable_with; +using cuda::std::nullptr_t; + +template +constexpr bool check_totally_ordered_with() noexcept { + constexpr bool result = totally_ordered_with; + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + static_assert(totally_ordered_with == result); + return result; +} + +namespace fundamentals { +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); + +struct S {}; +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int, int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int*, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int*, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int*, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int*, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int[5], int (S::*)() const volatile noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int[5], + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int[5], + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int[5], + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int[5], + int (S::*)() const volatile&& noexcept > ()); + +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (*)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (*)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (*)(), + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (*)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (*)(), + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (*)(), + int (S::*)() const volatile&& noexcept > ()); +#if TEST_STD_VER > 17 +static_assert(check_totally_ordered_with()); +#endif // TEST_STD_VER > 17 +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (&)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (&)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (&)(), + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (&)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (&)(), + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (&)(), + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)(), int (S::*)() const volatile noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)(), int (S::*)() const volatile & noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)(), + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)(), + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)(), + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)(), + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() noexcept, int (S::*)() const volatile noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() noexcept, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() noexcept, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() const, int (S::*)() const volatile noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() const, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() volatile, int (S::*)() const volatile noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() volatile, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() &, int (S::*)() const volatile & noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() & noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() & noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() & noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() & noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() const&, int (S::*)() const volatile & noexcept>()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile&, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + int (S::*)() const volatile & noexcept, int (S::*)() &&>()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile& noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with< + int (S::*)() const volatile & noexcept, int (S::*)() const&&>()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &&, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &&, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() &&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() && noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() const&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() volatile&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() && noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&&, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const&&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with < int (S::*)() const&& noexcept, + int (S::*)() const&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() const&& noexcept, + int (S::*)() volatile&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() const&& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() const&& noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() const&& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&&, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&&, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with < int (S::*)() volatile&& noexcept, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&& noexcept, + int (S::*)() const volatile&& > ()); +static_assert(!check_totally_ordered_with < int (S::*)() volatile&& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < int (S::*)() const volatile&&, + int (S::*)() const volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with < int (S::*)() + const volatile&& noexcept, + int (S::*)() const volatile&& noexcept > ()); + +#if !defined(TEST_COMPILER_GCC) +static_assert(!check_totally_ordered_with()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +#endif + +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + nullptr_t, int (S::*)() const volatile noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with< + nullptr_t, int (S::*)() const volatile & noexcept>()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < nullptr_t, + int (S::*)() && noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < nullptr_t, + int (S::*)() const&& noexcept > ()); +static_assert( + !check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < nullptr_t, + int (S::*)() volatile&& noexcept > ()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with < nullptr_t, + int (S::*)() const volatile&& noexcept > ()); + +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() && noexcept >); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() const&& noexcept >); +static_assert(!equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() volatile&& noexcept >); +static_assert( + !equality_comparable_with); +static_assert(!equality_comparable_with < void, + int (S::*)() const volatile&& noexcept >); +} // namespace fundamentals + +namespace standard_types { +static_assert( + check_totally_ordered_with, cuda::std::array >()); +static_assert(!check_totally_ordered_with, + cuda::std::array >()); +} // namespace standard_types + +namespace types_fit_for_purpose { +#if TEST_STD_VER > 17 +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); + +static_assert(check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +#endif // TEST_STD_VER > 17 + +static_assert( + check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert( + check_totally_ordered_with()); + +#if TEST_STD_VER > 17 +static_assert(!check_totally_ordered_with()); +static_assert( + cuda::std::common_reference_with && + !check_totally_ordered_with()); + +static_assert(!check_totally_ordered_with()); +static_assert( + cuda::std::common_reference_with && + !check_totally_ordered_with()); + +static_assert( + check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert( + check_totally_ordered_with()); + +static_assert(!check_totally_ordered_with()); +static_assert(!check_totally_ordered_with()); +static_assert(equality_comparable_with && + !check_totally_ordered_with()); +static_assert(equality_comparable_with && + !check_totally_ordered_with()); +static_assert(equality_comparable_with && + !check_totally_ordered_with()); +static_assert(equality_comparable_with && + !check_totally_ordered_with()); +static_assert(check_totally_ordered_with()); +static_assert( + check_totally_ordered_with()); + +static_assert( + cuda::std::totally_ordered&& + equality_comparable_with && + !check_totally_ordered_with()); +static_assert( + cuda::std::totally_ordered&& + equality_comparable_with && + !check_totally_ordered_with()); +static_assert( + cuda::std::totally_ordered&& + equality_comparable_with && + !check_totally_ordered_with()); +static_assert( + cuda::std::totally_ordered&& + equality_comparable_with && + !check_totally_ordered_with()); +#endif // TEST_STD_VER > 17 +} // namespace types_fit_for_purpose + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp new file mode 100644 index 0000000000..6e0c872e56 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept assignable_from = +// std::is_lvalue_reference_v && +// std::common_reference_with< +// const std::remove_reference_t&, +// const std::remove_reference_t&> && +// requires (LHS lhs, RHS&& rhs) { +// { lhs = std::forward(rhs) } -> std::same_as; +// }; + +#include +#include + +#include "MoveOnly.h" + +using namespace cuda::std; + +struct NoCommonRef { + NoCommonRef& operator=(const int&); +}; +static_assert(cuda::std::is_assignable_v); +static_assert(!assignable_from); // no common reference type + +struct Base {}; +struct Derived : Base {}; +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); + +struct VoidResultType { + void operator=(const VoidResultType&); +}; +static_assert(cuda::std::is_assignable_v); + +#if 0 +static_assert(cuda::std::is_same_v>); +static_assert(!assignable_from); + +struct ValueResultType { + ValueResultType operator=(const ValueResultType&); +}; +static_assert(cuda::std::is_assignable_v); +static_assert(!assignable_from); + +struct Locale { + const Locale& operator=(const Locale&); +}; +static_assert(cuda::std::is_assignable_v); +static_assert(!assignable_from); + +struct Tuple { + Tuple& operator=(const Tuple&); + const Tuple& operator=(const Tuple&) const; +}; +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); + +// Finally, check a few simple cases. +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert( assignable_from); +static_assert(!assignable_from); +static_assert(!assignable_from); +#endif + +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp new file mode 100644 index 0000000000..b00d5dc017 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp @@ -0,0 +1,1021 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept common_with; + +#include +#include + +#include "test_macros.h" + +using cuda::std::common_with; + +template +__host__ __device__ +constexpr bool CheckCommonWith() noexcept { + constexpr bool result = cuda::std::common_with; + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == result); + static_assert(cuda::std::common_with == + result); + return result; +} + +template +constexpr bool HasValidCommonType() noexcept { +#if TEST_STD_VER > 17 + return requires { typename cuda::std::common_type_t; } +#else +return cuda::std::_Common_type_exists +#endif + && std::same_as, std::common_type_t >; +} + +namespace BuiltinTypes { +// fundamental types +static_assert(cuda::std::common_with); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +#ifndef TEST_HAS_NO_INT128 +static_assert(CheckCommonWith()); +#endif +static_assert(CheckCommonWith()); + +// arrays +static_assert(CheckCommonWith()); + +// pointers +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); + +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +#if TEST_STD_VER > 17 +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +#endif // TEST_STD_VER > 17 +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); + +struct S {}; +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert( + CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert( + CheckCommonWith()); +static_assert(CheckCommonWith()); +static_assert(CheckCommonWith()); + +// nonsense +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert( + !CheckCommonWith()); +static_assert( + !CheckCommonWith()); +} // namespace BuiltinTypes + +namespace NoDefaultCommonType { +class T {}; + +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +static_assert(!CheckCommonWith()); +} // namespace NoDefaultCommonType + +struct BadBasicCommonType { + // This test is ill-formed, NDR. If it ever blows up in our faces: that's a good thing. + // In the meantime, the test should be included. If compiler support is added, then an include guard + // should be placed so the test doesn't get deleted. +}; + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = BadBasicCommonType; +}; + +template <> +struct common_type { + using type = int; +}; +} // namespace std +} // namespace cuda +static_assert(cuda::std::_Common_type_exists); +static_assert(cuda::std::_Common_type_exists); +static_assert(!cuda::std::same_as, + cuda::std::common_type_t >); +static_assert(!CheckCommonWith()); + +struct DullCommonType {}; +static_assert(!cuda::std::convertible_to); + +struct T1 {}; +static_assert(!cuda::std::convertible_to); + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = DullCommonType; +}; + +template <> +struct common_type { + using type = DullCommonType; +}; +} // namespace std +} // namespace cuda +static_assert(cuda::std::_Common_type_exists); +static_assert(cuda::std::_Common_type_exists); +static_assert(cuda::std::same_as, DullCommonType>); +static_assert(cuda::std::same_as, DullCommonType>); +static_assert(HasValidCommonType()); +static_assert(!CheckCommonWith()); + +#if TEST_STD_VER > 17 +struct CommonTypeImplicitlyConstructibleFromInt { + explicit(false) CommonTypeImplicitlyConstructibleFromInt(int); +}; +static_assert(requires { + static_cast(0); +}); + +struct T2 {}; +static_assert( + !cuda::std::convertible_to); + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeImplicitlyConstructibleFromInt; +}; + +template <> +struct common_type { + using type = CommonTypeImplicitlyConstructibleFromInt; +}; +} // namespace std +} // namespace cuda +static_assert(HasValidCommonType()); +static_assert(!CheckCommonWith()); + +struct CommonTypeExplicitlyConstructibleFromInt { + explicit CommonTypeExplicitlyConstructibleFromInt(int); +}; +static_assert(requires { + static_cast(0); +}); + +struct T3 {}; +static_assert( + !cuda::std::convertible_to); + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeExplicitlyConstructibleFromInt; +}; + +template <> +struct common_type { + using type = CommonTypeExplicitlyConstructibleFromInt; +}; +} // namespace std +} // namespace cuda +static_assert(HasValidCommonType()); +static_assert(!CheckCommonWith()); + +struct T4 {}; +struct CommonTypeImplicitlyConstructibleFromT4 { + explicit(false) CommonTypeImplicitlyConstructibleFromT4(T4); +}; +static_assert(requires(T4 t4) { + static_cast(t4); +}); + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeImplicitlyConstructibleFromT4; +}; + +template <> +struct common_type { + using type = CommonTypeImplicitlyConstructibleFromT4; +}; +} // namespace std +} // namespace cuda +static_assert(HasValidCommonType()); +static_assert(!CheckCommonWith()); + +struct T5 {}; +struct CommonTypeExplicitlyConstructibleFromT5 { + explicit CommonTypeExplicitlyConstructibleFromT5(T5); +}; +static_assert(requires(T5 t5) { + static_cast(t5); +}); + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeExplicitlyConstructibleFromT5; +}; + +template <> +struct common_type { + using type = CommonTypeExplicitlyConstructibleFromT5; +}; +} // namespace std +} // namespace cuda +static_assert(HasValidCommonType()); +static_assert(!CheckCommonWith()); +#endif // TEST_STD_VER > 17 + +struct T6 {}; +struct CommonTypeNoCommonReference { + CommonTypeNoCommonReference(T6); + CommonTypeNoCommonReference(int); +}; + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeNoCommonReference; +}; + +template <> +struct common_type { + using type = CommonTypeNoCommonReference; +}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; + +template <> +struct common_type {}; +} // namespace std +} // namespace cuda + +template +constexpr bool HasCommonReference() noexcept { + return cuda::std::_Common_reference_exists; +} + +static_assert(HasValidCommonType()); +static_assert(!HasCommonReference()); +static_assert(!CheckCommonWith()); + +struct T7 {}; +struct CommonTypeNoMetaCommonReference { + CommonTypeNoMetaCommonReference(T7); + CommonTypeNoMetaCommonReference(int); +}; + +namespace cuda { +namespace std { +template <> +struct common_type { + using type = CommonTypeNoMetaCommonReference; +}; + +template <> +struct common_type { + using type = CommonTypeNoMetaCommonReference; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; + +template <> +struct common_type { + using type = void; +}; +} // namespace std +} // namespace cuda +static_assert(HasValidCommonType()); +static_assert(HasValidCommonType()); +static_assert(HasCommonReference()); +static_assert( + !HasCommonReference&, + cuda::std::common_reference_t >()); +static_assert(!CheckCommonWith()); + +struct CommonWithInt { + operator int() const volatile; +}; + +namespace std { +template <> +struct common_type { + using type = int; +}; + +template <> +struct common_type : common_type {}; + +template <> +struct common_type : common_type {}; + +template <> +struct common_type : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; +} // namespace std +static_assert(CheckCommonWith()); + +struct CommonWithIntButRefLong { + operator int() const volatile; +}; + +namespace std { +template <> +struct common_type { + using type = int; +}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type { + using type = long; +}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; + +template <> +struct common_type + : common_type {}; +} // namespace std +static_assert(CheckCommonWith()); +int main(int, char**) { return 0; } diff --git a/.upstream-tests/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp b/.upstream-tests/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp new file mode 100644 index 0000000000..707ae7ca58 --- /dev/null +++ b/.upstream-tests/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp @@ -0,0 +1,376 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11 + +// template +// concept common_reference_with; + +#include +#include + +#include "test_macros.h" + +using cuda::std::common_reference_with; + +template +__host__ __device__ +constexpr bool CheckCommonReferenceWith() noexcept { + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert(common_reference_with); + static_assert( + common_reference_with); + + return common_reference_with; +} + +namespace BuiltinTypes { +// fundamental types +static_assert(common_reference_with); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +#ifndef TEST_HAS_NO_INT128 +static_assert(CheckCommonReferenceWith()); +#endif +static_assert(CheckCommonReferenceWith()); + +// arrays +static_assert(CheckCommonReferenceWith()); + +// pointers (common with void*) +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert( + CheckCommonReferenceWith()); + +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +struct S {}; +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert( + CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert( + CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); +static_assert(CheckCommonReferenceWith()); + +// nonsense +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +} // namespace BuiltinTypes + +namespace NoDefaultCommonReference { +class T {}; + +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +static_assert(!common_reference_with); +static_assert(!common_reference_with); +static_assert( + !common_reference_with); +} // namespace NoDefaultCommonReference + + +struct s2 {}; +struct convertible_with_const_s2 { + operator s2 const &() const; +}; +static_assert(common_reference_with); + +struct convertible_with_volatile_s2 { + operator s2 volatile &() volatile; +}; +static_assert(common_reference_with); + +struct BadBasicCommonReference { + // This test is ill-formed, NDR. If it ever blows up in our faces: that's a good thing. + // In the meantime, the test should be included. If compiler support is added, then an include guard + // should be placed so the test doesn't get deleted. + operator int() const; + operator int&(); +}; +static_assert(cuda::std::convertible_to); +static_assert(cuda::std::convertible_to); + +namespace cuda { +namespace std { +template