]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/any/cons/nontrivial.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / any / cons / nontrivial.cc
CommitLineData
85ec4feb 1// Copyright (C) 2015-2018 Free Software Foundation, Inc.
52e86221
VV
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.
8
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.
13
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/>.
17
18// { dg-options "-std=gnu++17" }
19
20#include <any>
21#include <testsuite_hooks.h>
22
23struct LocationAware
24{
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; }
31
32 void* const self = this;
33};
34static_assert(std::is_nothrow_move_constructible<LocationAware>::value, "");
35static_assert(!std::is_trivially_copyable<LocationAware>::value, "");
36
37using std::any;
38
39void
40test01()
41{
42
43 LocationAware l;
44 any a = l;
45}
46
47void
48test02()
49{
50 LocationAware l;
51 any a = l;
52 any b = a;
53 {
54 any tmp = std::move(a);
55 a = std::move(b);
56 b = std::move(tmp);
57 }
58}
59
60void
61test03()
62{
63 LocationAware l;
64 any a = l;
65 any b = a;
66 swap(a, b);
67}
68
69int
70main()
71{
72 test01();
73 test02();
74 test03();
75}