Add missing dg-require-cstdint directives to tests
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / any / cons / nontrivial.cc
blob504d03ee8c03224fa2ba6a76df4ec8f5ec6437e4
1 // Copyright (C) 2015-2018 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++17" }
20 #include <any>
21 #include <testsuite_hooks.h>
23 struct LocationAware
25 LocationAware() { }
26 ~LocationAware() { VERIFY(self == this); }
27 LocationAware(const LocationAware&) { }
28 LocationAware& operator=(const LocationAware&) { return *this; }
29 LocationAware(LocationAware&&) noexcept { }
30 LocationAware& operator=(LocationAware&&) noexcept { return *this; }
32 void* const self = this;
34 static_assert(std::is_nothrow_move_constructible<LocationAware>::value, "");
35 static_assert(!std::is_trivially_copyable<LocationAware>::value, "");
37 using std::any;
39 void
40 test01()
43 LocationAware l;
44 any a = l;
47 void
48 test02()
50 LocationAware l;
51 any a = l;
52 any b = a;
54 any tmp = std::move(a);
55 a = std::move(b);
56 b = std::move(tmp);
60 void
61 test03()
63 LocationAware l;
64 any a = l;
65 any b = a;
66 swap(a, b);
69 int
70 main()
72 test01();
73 test02();
74 test03();