]>
Commit | Line | Data |
---|---|---|
b2343559 JW |
1 | // { dg-do run { target c++11 } } |
2 | ||
99dee823 | 3 | // Copyright (C) 2016-2021 Free Software Foundation, Inc. |
b2343559 JW |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | #include <memory> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | struct A | |
24 | { | |
25 | int i = 0; | |
26 | }; | |
27 | ||
7b936140 | 28 | // C++17 20.11.2.2.5 shared_ptr observers [util.smartptr.shared.obs] |
b2343559 JW |
29 | |
30 | // get | |
31 | void | |
32 | test01() | |
33 | { | |
34 | A * const a = new A[2]; | |
35 | const std::shared_ptr<A[2]> p(a); | |
36 | VERIFY( p.get() == a ); | |
37 | } | |
38 | ||
39 | // get | |
40 | void | |
41 | test02() | |
42 | { | |
43 | A * const a = new A[2]; | |
44 | const std::shared_ptr<A[]> p(a); | |
45 | VERIFY( p.get() == a ); | |
46 | } | |
47 | ||
48 | // operator[] | |
49 | void | |
50 | test03() | |
51 | { | |
52 | A * const a = new A[2]; | |
53 | const std::shared_ptr<A[2]> p(a); | |
54 | VERIFY( &p[0] == a ); | |
55 | } | |
56 | ||
57 | // operator[] | |
58 | void | |
59 | test04() | |
60 | { | |
61 | A * const a = new A[2]; | |
62 | const std::shared_ptr<A[]> p(a); | |
63 | VERIFY( &p[0] == a ); | |
64 | } | |
65 | ||
66 | int | |
67 | main() | |
68 | { | |
69 | test01(); | |
70 | test02(); | |
71 | test03(); | |
72 | test04(); | |
73 | } |