1 Upstream-Status: Inappropriate [Backport]
2 From 2ce87b6b9c9143a22381eec77bbf1fd7016e132d Mon Sep 17 00:00:00 2001
3 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Sat, 16 Apr 2011 00:55:53 +0000
5 Subject: [PATCH 129/200] 2011-04-15 Daniel Krugler <daniel.kruegler@googlemail.com>
6 Paolo Carlini <paolo.carlini@oracle.com>
9 * include/bits/unique_ptr.h (unique_ptr<>::operator=(unique_ptr&&),
10 unique_ptr<>::operator=(unique_ptr<>&&),
11 unique_ptr<_Tp[],>::operator=(unique_ptr&&),
12 unique_ptr<_Tp[],>::operator=(unique_ptr<>&&)): Forward the deleter
14 * testsuite/20_util/unique_ptr/assign/48635.cc: New.
17 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172533 138bc75d-0d04-0410-961f-82ee72b054a4
19 index 5df4325..1be2e7a 100644
20 --- a/libstdc++-v3/include/bits/unique_ptr.h
21 +++ b/libstdc++-v3/include/bits/unique_ptr.h
22 @@ -171,7 +171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
23 operator=(unique_ptr&& __u)
26 - get_deleter() = std::move(__u.get_deleter());
27 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
31 @@ -184,7 +184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
32 operator=(unique_ptr<_Up, _Ep>&& __u)
35 - get_deleter() = std::move(__u.get_deleter());
36 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
40 @@ -315,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
41 operator=(unique_ptr&& __u)
44 - get_deleter() = std::move(__u.get_deleter());
45 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
49 @@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 operator=(unique_ptr<_Up, _Ep>&& __u)
53 - get_deleter() = std::move(__u.get_deleter());
54 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
58 diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
60 index 0000000..99b412b
62 +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
64 +// { dg-options "-std=gnu++0x" }
66 +// Copyright (C) 2011 Free Software Foundation
68 +// This file is part of the GNU ISO C++ Library. This library is free
69 +// software; you can redistribute it and/or modify it under the
70 +// terms of the GNU General Public License as published by the
71 +// Free Software Foundation; either version 3, or (at your option)
72 +// any later version.
74 +// This library is distributed in the hope that it will be useful,
75 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
76 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77 +// GNU General Public License for more details.
79 +// You should have received a copy of the GNU General Public License along
80 +// with this library; see the file COPYING3. If not see
81 +// <http://www.gnu.org/licenses/>.
84 +#include <testsuite_hooks.h>
88 + Deleter() = default;
89 + Deleter(const Deleter&) = default;
90 + Deleter(Deleter&&) = default;
93 + operator=(const Deleter&)
95 + bool test __attribute__((unused)) = true;
101 + operator=(Deleter&&)
103 + bool test __attribute__((unused)) = true;
110 + operator()(T*) const { }
113 +struct DDeleter : Deleter { };
120 + std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d);
121 + p2 = std::move(p1);
125 + std::unique_ptr<int, DDeleter&> p1t(nullptr, dd);
126 + std::unique_ptr<int, Deleter&> p2t(nullptr, d);
127 + p2t = std::move(p1t);
129 + std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d);
130 + p2a = std::move(p1a);
132 + std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd);
133 + std::unique_ptr<int[], Deleter&> p2at(nullptr, d);
134 + p2at = std::move(p1at);