]>
Commit | Line | Data |
---|---|---|
d38d26be | 1 | // { dg-do run { target c++11 } } |
7cc9022f AA |
2 | // { dg-require-effective-target hosted } |
3 | ||
d38d26be JW |
4 | #include <functional> |
5 | #include <testsuite_hooks.h> | |
6 | ||
7 | struct Funk | |
8 | { | |
9 | Funk() = default; | |
10 | Funk(const Funk&) { ++copies; } | |
11 | Funk(Funk&&) { ++moves; } | |
12 | ||
13 | void operator()() const { } | |
14 | ||
15 | static int copies; | |
16 | static int moves; | |
17 | }; | |
18 | ||
19 | int Funk::copies = 0; | |
20 | int Funk::moves = 0; | |
21 | ||
22 | int main() | |
23 | { | |
24 | Funk e; | |
25 | // LWG 2774 means there should be no move here: | |
26 | std::function<void()> fc(e); | |
27 | VERIFY(Funk::copies == 1); | |
28 | VERIFY(Funk::moves == 0); | |
29 | // And only one move here: | |
30 | std::function<void()> fm(std::move(e)); | |
31 | VERIFY(Funk::copies == 1); | |
32 | VERIFY(Funk::moves == 1); | |
33 | } |