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 // test forward 10 11 #include <utility> 12 13 #include "test_macros.h" 14 15 struct A 16 { 17 }; 18 19 A source() {return A();} 20 const A csource() {return A();} 21 22 int main(int, char**) 23 { 24 #if TEST_STD_VER >= 11 25 { 26 std::forward<A&>(source()); // expected-note {{requested here}} 27 // expected-error-re@type_traits:* 1 {{static_assert failed{{.*}} "can not forward an rvalue as an lvalue"}} 28 } 29 #else 30 { 31 std::forward<A&>(source()); // expected-error {{no matching function for call to 'forward'}} 32 } 33 #endif 34 { 35 const A ca = A(); 36 std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}} 37 } 38 { 39 std::forward<A&>(csource()); // expected-error {{no matching function for call to 'forward'}} 40 } 41 { 42 const A ca = A(); 43 std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}} 44 } 45 { 46 std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}} 47 } 48 { 49 A a; 50 std::forward(a); // expected-error {{no matching function for call to 'forward'}} 51 } 52 53 return 0; 54 } 55