1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // test forward 11 12 #include <utility> 13 14 #include "test_macros.h" 15 16 struct A 17 { 18 }; 19 20 A source() {return A();} 21 const A csource() {return A();} 22 23 int main() 24 { 25 #if TEST_STD_VER >= 11 26 { 27 std::forward<A&>(source()); // expected-note {{requested here}} 28 // expected-error@type_traits:* 1 {{static_assert failed "can not forward an rvalue as an lvalue"}} 29 } 30 #else 31 { 32 std::forward<A&>(source()); // expected-error {{no matching function for call to 'forward'}} 33 } 34 #endif 35 { 36 const A ca = A(); 37 std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}} 38 } 39 { 40 std::forward<A&>(csource()); // expected-error {{no matching function for call to 'forward'}} 41 } 42 { 43 const A ca = A(); 44 std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}} 45 } 46 { 47 std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}} 48 } 49 { 50 A a; 51 std::forward(a); // expected-error {{no matching function for call to 'forward'}} 52 } 53 } 54