]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do compile { target c++11 } } |
aaf0ca6f | 2 | |
a5544970 | 3 | // Copyright (C) 2008-2019 Free Software Foundation, Inc. |
aaf0ca6f 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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
aaf0ca6f JW |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
aaf0ca6f | 19 | |
640cbe76 | 20 | // 20.7.12.2 Template class shared_ptr [util.smartptr.shared] |
aaf0ca6f JW |
21 | |
22 | #include <memory> | |
aaf0ca6f JW |
23 | |
24 | struct A { }; | |
640cbe76 | 25 | std::unique_ptr<A> source() { return std::unique_ptr<A>(); } |
aaf0ca6f | 26 | |
640cbe76 | 27 | // 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] |
aaf0ca6f | 28 | |
640cbe76 | 29 | // Assignment from rvalue unique_ptr |
6f3b8891 | 30 | void |
aaf0ca6f JW |
31 | test01() |
32 | { | |
aaf0ca6f | 33 | std::shared_ptr<A> a; |
640cbe76 | 34 | a = source(); |
640cbe76 JW |
35 | } |
36 | ||
6f3b8891 | 37 | void |
640cbe76 JW |
38 | test02() |
39 | { | |
640cbe76 JW |
40 | std::shared_ptr<A> a; |
41 | std::unique_ptr<A> u; | |
42 | a = std::move(u); | |
aaf0ca6f JW |
43 | } |
44 | ||
45 | int | |
46 | main() | |
47 | { | |
48 | test01(); | |
640cbe76 | 49 | test02(); |
aaf0ca6f JW |
50 | return 0; |
51 | } |