From ecebd899c9895413bb4ede7b91f77fd733d6b82e Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sat, 15 Feb 2025 13:52:31 +0100 Subject: [PATCH] [libc++] Verifies std::forward_like's mandates clause. The existing using _ForwardLike declaration already fails with a subsitution failure. The LWG issue was filed to clarify what should happen for non-referencable types. Added test to verify libc++ is alrady enforcing the new mandates. Implements: - LWG3757 What's the effect of std::forward_like(x) Closes: #105026 --- libcxx/docs/Status/Cxx23Issues.csv | 2 +- .../utility/forward/forward_like.verify.cpp | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 libcxx/test/std/utilities/utility/forward/forward_like.verify.cpp diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv index 1215f21985eb9..6471fdbf069a3 100644 --- a/libcxx/docs/Status/Cxx23Issues.csv +++ b/libcxx/docs/Status/Cxx23Issues.csv @@ -213,7 +213,7 @@ "`LWG3753 `__","Clarify entity vs. freestanding entity","2022-11 (Kona)","","","" "`LWG3754 `__","Class template expected synopsis contains declarations that do not match the detailed description","2022-11 (Kona)","|Nothing To Do|","","" "`LWG3755 `__","``tuple-for-each`` can call ``user-defined`` ``operator,``","2022-11 (Kona)","|Complete|","17","" -"`LWG3757 `__","What's the effect of ``std::forward_like(x)``?","2022-11 (Kona)","","","" +"`LWG3757 `__","What's the effect of ``std::forward_like(x)``?","2022-11 (Kona)","|Nothing To Do|","","" "`LWG3759 `__","``ranges::rotate_copy`` should use ``std::move``","2022-11 (Kona)","|Complete|","15","" "`LWG3760 `__","``cartesian_product_view::iterator``'s ``parent_`` is never valid","2022-11 (Kona)","","","" "`LWG3761 `__","``cartesian_product_view::iterator::operator-`` should pass by reference","2022-11 (Kona)","","","" diff --git a/libcxx/test/std/utilities/utility/forward/forward_like.verify.cpp b/libcxx/test/std/utilities/utility/forward/forward_like.verify.cpp new file mode 100644 index 0000000000000..279f0e60a1c38 --- /dev/null +++ b/libcxx/test/std/utilities/utility/forward/forward_like.verify.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++23 + +// + +// template +// [[nodiscard]] constexpr +// auto forward_like(auto&& x) noexcept -> see below; + +// Mandates: T is a referenceable type (3.45 [defns.referenceable]). + +#include + +struct incomplete; + +void test() { + int i; + (void)std::forward_like(i); + + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + + using fp = void(); + using cfp = void() const; + using vfp = void() volatile; + using cvfp = void() const volatile; + (void)std::forward_like(i); + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + + using fpr = void()&; + using fprr = void()&&; + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} + (void)std::forward_like(i); // expected-error {{no matching function for call to 'forward_like'}} +}