aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/utility/forward/forward.fail.cpp
blob: c845216d86dc52bac0d4367cef4d7463b46b54c4 (plain) (blame)
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
49
50
51
52
53
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// test forward

#include <utility>

#include "test_macros.h"

struct A
{
};

A source() {return A();}
const A csource() {return A();}

int main()
{
#if TEST_STD_VER >= 11
    {
        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"}}
    }
#else
    {
        std::forward<A&>(source()); // expected-error {{no matching function for call to 'forward'}}
    }
#endif
    {
        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'}}
    }
}