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 
source()19 A source() {return A();}
csource()20 const A csource() {return A();}
21 
main(int,char **)22 int main(int, char**)
23 {
24     {
25         std::forward<A&>(source());  // expected-note {{requested here}}
26         // expected-error-re@type_traits:* 1 {{static_assert failed{{.*}} "can not forward an rvalue as an lvalue"}}
27     }
28     {
29         const A ca = A();
30         std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}
31     }
32     {
33         std::forward<A&>(csource());  // expected-error {{no matching function for call to 'forward'}}
34     }
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         A a;
44         std::forward(a); // expected-error {{no matching function for call to 'forward'}}
45     }
46 
47   return 0;
48 }
49