47 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// REQUIRES: std-at-least-c++2310 11// <utility>12 13// template <typename T>14// [[nodiscard]] constexpr15// 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 21struct incomplete;22 23void 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}47