PR libstdc++/87278 restore support for std::make_shared<volatile T>()
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / shared_ptr / observers / array.cc
blobd9b5fe329de83b0e6f49365c0439509972689d59
1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2016-2018 Free Software Foundation, Inc.
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.
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.
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/>.
20 #include <memory>
21 #include <testsuite_hooks.h>
23 struct A
25 int i = 0;
28 // C++17 20.11.2.2.5 shared_ptr observers [util.smartptr.shared.obs]
30 // get
31 void
32 test01()
34 A * const a = new A[2];
35 const std::shared_ptr<A[2]> p(a);
36 VERIFY( p.get() == a );
39 // get
40 void
41 test02()
43 A * const a = new A[2];
44 const std::shared_ptr<A[]> p(a);
45 VERIFY( p.get() == a );
48 // operator[]
49 void
50 test03()
52 A * const a = new A[2];
53 const std::shared_ptr<A[2]> p(a);
54 VERIFY( &p[0] == a );
57 // operator[]
58 void
59 test04()
61 A * const a = new A[2];
62 const std::shared_ptr<A[]> p(a);
63 VERIFY( &p[0] == a );
66 int
67 main()
69 test01();
70 test02();
71 test03();
72 test04();