blob: 7dcdf25c538636e79e216a5282eafe367e820608 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// test forward
#include <utility>
#include "test_macros.h"
struct A
{
};
A source() {return A();}
const A csource() {return A();}
int main(int, char**)
{
{
std::forward<A&>(source()); // expected-note {{requested here}}
// expected-error-re@type_traits:* 1 {{static_assert failed{{.*}} "can not forward an rvalue as an lvalue"}}
}
{
const A ca = A();
std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}
}
{
std::forward<A&>(csource()); // expected-error {{no matching function for call to 'forward'}}
}
{
const A ca = A();
std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}}
}
{
std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}}
}
{
A a;
std::forward(a); // expected-error {{no matching function for call to 'forward'}}
}
return 0;
}
|