Skip to content

Commit f9aa7a2

Browse files
authored
[libc++] Verify std::forward_like's mandates clause. (#127318)
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 already enforcing the new Mandates. Implements: - LWG3757 What's the effect of std::forward_like<void>(x) Closes: #105026
1 parent a629b50 commit f9aa7a2

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

libcxx/docs/Status/Cxx23Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"`LWG3753 <https://wg21.link/LWG3753>`__","Clarify entity vs. freestanding entity","2022-11 (Kona)","","",""
214214
"`LWG3754 <https://wg21.link/LWG3754>`__","Class template expected synopsis contains declarations that do not match the detailed description","2022-11 (Kona)","|Nothing To Do|","",""
215215
"`LWG3755 <https://wg21.link/LWG3755>`__","``tuple-for-each`` can call ``user-defined`` ``operator,``","2022-11 (Kona)","|Complete|","17",""
216-
"`LWG3757 <https://wg21.link/LWG3757>`__","What's the effect of ``std::forward_like<void>(x)``?","2022-11 (Kona)","","",""
216+
"`LWG3757 <https://wg21.link/LWG3757>`__","What's the effect of ``std::forward_like<void>(x)``?","2022-11 (Kona)","|Nothing To Do|","",""
217217
"`LWG3759 <https://wg21.link/LWG3759>`__","``ranges::rotate_copy`` should use ``std::move``","2022-11 (Kona)","|Complete|","15",""
218218
"`LWG3760 <https://wg21.link/LWG3760>`__","``cartesian_product_view::iterator``'s ``parent_`` is never valid","2022-11 (Kona)","","",""
219219
"`LWG3761 <https://wg21.link/LWG3761>`__","``cartesian_product_view::iterator::operator-`` should pass by reference","2022-11 (Kona)","","",""
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: std-at-least-c++23
10+
11+
// <utility>
12+
13+
// template <typename T>
14+
// [[nodiscard]] constexpr
15+
// auto forward_like(auto&& x) noexcept -> see below;
16+
17+
// Mandates: T is a referenceable type (3.45 [defns.referenceable]).
18+
19+
#include <utility>
20+
21+
struct incomplete;
22+
23+
void test() {
24+
int i;
25+
(void)std::forward_like<incomplete>(i);
26+
27+
(void)std::forward_like<void>(i); // expected-error {{no matching function for call to 'forward_like'}}
28+
(void)std::forward_like<const void>(i); // expected-error {{no matching function for call to 'forward_like'}}
29+
(void)std::forward_like<volatile void>(i); // expected-error {{no matching function for call to 'forward_like'}}
30+
(void)std::forward_like<const volatile void>(i); // expected-error {{no matching function for call to 'forward_like'}}
31+
32+
using fp = void();
33+
using cfp = void() const;
34+
using vfp = void() volatile;
35+
using cvfp = void() const volatile;
36+
(void)std::forward_like<fp>(i);
37+
(void)std::forward_like<cfp>(i); // expected-error {{no matching function for call to 'forward_like'}}
38+
(void)std::forward_like<cfp>(i); // expected-error {{no matching function for call to 'forward_like'}}
39+
(void)std::forward_like<vfp>(i); // expected-error {{no matching function for call to 'forward_like'}}
40+
(void)std::forward_like<cvfp>(i); // expected-error {{no matching function for call to 'forward_like'}}
41+
42+
using fpr = void()&;
43+
using fprr = void()&&;
44+
(void)std::forward_like<fpr>(i); // expected-error {{no matching function for call to 'forward_like'}}
45+
(void)std::forward_like<fprr>(i); // expected-error {{no matching function for call to 'forward_like'}}
46+
}

0 commit comments

Comments
 (0)