]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/memory/observer_ptr/requirements.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / memory / observer_ptr / requirements.cc
1 // { dg-options "-std=gnu++14" }
2 // { dg-do compile }
3
4 // Copyright (C) 2015-2016 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a moved_to of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <experimental/memory>
22
23 using std::experimental::observer_ptr;
24
25 struct nontrivial {nontrivial() {}};
26 struct other {};
27 struct base {};
28 struct derived : base {};
29
30 static_assert(!std::is_trivially_constructible<
31 observer_ptr<nontrivial>>::value, "");
32 static_assert(std::is_trivially_copyable<
33 observer_ptr<nontrivial>>::value, "");
34 static_assert(std::is_trivially_destructible<
35 observer_ptr<nontrivial>>::value, "");
36
37 static_assert(std::is_constructible<
38 observer_ptr<nontrivial>, nontrivial*>::value,
39 "");
40 static_assert(std::is_constructible<observer_ptr<base>, base*>::value, "");
41 static_assert(std::is_constructible<observer_ptr<base>, derived*>::value, "");
42 static_assert(!std::is_constructible<observer_ptr<base>, other*>::value, "");
43 static_assert(std::is_constructible<
44 observer_ptr<base>, observer_ptr<base>>::value, "");
45 static_assert(std::is_constructible<
46 observer_ptr<base>, observer_ptr<derived>>::value, "");
47 static_assert(!std::is_constructible<
48 observer_ptr<base>, observer_ptr<other>>::value, "");
49
50 static_assert(!std::is_assignable<
51 observer_ptr<nontrivial>, nontrivial*>::value,
52 "");
53 static_assert(std::is_assignable<
54 observer_ptr<nontrivial>, observer_ptr<nontrivial>>::value,
55 "");
56 static_assert(std::is_assignable<observer_ptr<base>,
57 observer_ptr<base>>::value, "");
58 static_assert(std::is_assignable<observer_ptr<base>,
59 observer_ptr<derived>>::value, "");
60 static_assert(!std::is_assignable<
61 observer_ptr<base>, observer_ptr<other>>::value, "");
62 static_assert(std::is_assignable<observer_ptr<const int>,
63 observer_ptr<int>>::value, "");
64 static_assert(!std::is_assignable<observer_ptr<int>,
65 observer_ptr<const int>>::value, "");