]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
2705a8d6 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2011-2023 Free Software Foundation, Inc. |
2705a8d6 DK |
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 Deleter | |
24 | { | |
25 | Deleter() = default; | |
26 | Deleter(const Deleter&) = default; | |
27 | Deleter(Deleter&&) = default; | |
28 | ||
29 | Deleter& | |
30 | operator=(const Deleter&) | |
31 | { | |
2705a8d6 DK |
32 | VERIFY( true ); |
33 | return *this; | |
34 | } | |
35 | ||
36 | Deleter& | |
37 | operator=(Deleter&&) | |
38 | { | |
2705a8d6 DK |
39 | VERIFY( false ); |
40 | return *this; | |
41 | } | |
42 | ||
43 | template<class T> | |
44 | void | |
45 | operator()(T*) const { } | |
46 | }; | |
47 | ||
48 | struct DDeleter : Deleter { }; | |
49 | ||
50 | // libstdc++/48635 | |
51 | void test01() | |
52 | { | |
53 | Deleter d; | |
54 | ||
55 | std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d); | |
56 | p2 = std::move(p1); | |
57 | ||
58 | DDeleter dd; | |
59 | ||
2705a8d6 DK |
60 | std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d); |
61 | p2a = std::move(p1a); | |
2705a8d6 DK |
62 | } |
63 | ||
64 | int main() | |
65 | { | |
66 | test01(); | |
67 | return 0; | |
68 | } |