]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/unique_ptr/54351.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / 54351.cc
CommitLineData
8868286e 1// { dg-options "-std=gnu++11" }
9acc9f78 2// { dg-do run }
3
f1717362 4// Copyright (C) 2012-2016 Free Software Foundation, Inc.
9acc9f78 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 copy 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// 20.7.1 Template class unique_ptr [unique.ptr]
22
23#include <memory>
24#include <testsuite_hooks.h>
25
26struct A;
27
28struct B
29{
30 std::unique_ptr<A> a;
31};
32
33struct A
34{
35 B* b;
36 ~A() { VERIFY(b->a != nullptr); }
37};
38
39void test01()
40{
41 B b;
42 b.a.reset(new A);
43 b.a->b = &b;
44}
45
46struct C;
47
48struct D
49{
50 std::unique_ptr<C[]> c;
51};
52
53struct C
54{
55 D* d;
56 ~C() { VERIFY(d->c != nullptr); }
57};
58
59void test02()
60{
61 D d;
62 d.c.reset(new C[1]);
63 d.c[0].d = &d;
64}
65
66int main()
67{
68 test01();
69 test02();
70}