]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/function/cons/lwg2774.cc
libstdc++: Disable hosted-only tests [PR103626]
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / function / cons / lwg2774.cc
CommitLineData
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
7struct 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
19int Funk::copies = 0;
20int Funk::moves = 0;
21
22int 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}