1 From 2ce87b6b9c9143a22381eec77bbf1fd7016e132d Mon Sep 17 00:00:00 2001
2 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Sat, 16 Apr 2011 00:55:53 +0000
4 Subject: [PATCH 129/200] 2011-04-15 Daniel Krugler <daniel.kruegler@googlemail.com>
5 Paolo Carlini <paolo.carlini@oracle.com>
8 * include/bits/unique_ptr.h (unique_ptr<>::operator=(unique_ptr&&),
9 unique_ptr<>::operator=(unique_ptr<>&&),
10 unique_ptr<_Tp[],>::operator=(unique_ptr&&),
11 unique_ptr<_Tp[],>::operator=(unique_ptr<>&&)): Forward the deleter
13 * testsuite/20_util/unique_ptr/assign/48635.cc: New.
16 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172533 138bc75d-0d04-0410-961f-82ee72b054a4
18 index 5df4325..1be2e7a 100644
19 --- a/libstdc++-v3/include/bits/unique_ptr.h
20 +++ b/libstdc++-v3/include/bits/unique_ptr.h
21 @@ -171,7 +171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
22 operator=(unique_ptr&& __u)
25 - get_deleter() = std::move(__u.get_deleter());
26 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
30 @@ -184,7 +184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
31 operator=(unique_ptr<_Up, _Ep>&& __u)
34 - get_deleter() = std::move(__u.get_deleter());
35 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
39 @@ -315,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
40 operator=(unique_ptr&& __u)
43 - get_deleter() = std::move(__u.get_deleter());
44 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
48 @@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 operator=(unique_ptr<_Up, _Ep>&& __u)
52 - get_deleter() = std::move(__u.get_deleter());
53 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
57 diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
59 index 0000000..99b412b
61 +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
63 +// { dg-options "-std=gnu++0x" }
65 +// Copyright (C) 2011 Free Software Foundation
67 +// This file is part of the GNU ISO C++ Library. This library is free
68 +// software; you can redistribute it and/or modify it under the
69 +// terms of the GNU General Public License as published by the
70 +// Free Software Foundation; either version 3, or (at your option)
71 +// any later version.
73 +// This library is distributed in the hope that it will be useful,
74 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
75 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 +// GNU General Public License for more details.
78 +// You should have received a copy of the GNU General Public License along
79 +// with this library; see the file COPYING3. If not see
80 +// <http://www.gnu.org/licenses/>.
83 +#include <testsuite_hooks.h>
87 + Deleter() = default;
88 + Deleter(const Deleter&) = default;
89 + Deleter(Deleter&&) = default;
92 + operator=(const Deleter&)
94 + bool test __attribute__((unused)) = true;
100 + operator=(Deleter&&)
102 + bool test __attribute__((unused)) = true;
109 + operator()(T*) const { }
112 +struct DDeleter : Deleter { };
119 + std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d);
120 + p2 = std::move(p1);
124 + std::unique_ptr<int, DDeleter&> p1t(nullptr, dd);
125 + std::unique_ptr<int, Deleter&> p2t(nullptr, d);
126 + p2t = std::move(p1t);
128 + std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d);
129 + p2a = std::move(p1a);
131 + std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd);
132 + std::unique_ptr<int[], Deleter&> p2at(nullptr, d);
133 + p2at = std::move(p1at);