OSDN Git Service

2011-04-17 Daniel Krugler <daniel.kruegler@googlemail.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / assign / 48635_neg.cc
1 // { dg-options "-std=gnu++0x" }
2 // { dg-do compile }
3
4 // Copyright (C) 2011 Free Software Foundation
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License
18 // along with this library; see the file COPYING3.  If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <memory>
22
23 struct D;
24
25 struct B
26 {
27  B& operator=(D&) = delete; // { dg-error "declared here" }
28
29  template<class T>
30    void operator()(T*) const {}
31 };
32
33 struct D : B { };
34
35 // libstdc++/48635
36 void f()
37 {
38   B b;
39   D d;
40
41   std::unique_ptr<int, B&> ub(nullptr, b);
42   std::unique_ptr<int, D&> ud(nullptr, d);
43   ub = std::move(ud);
44 // { dg-error "use of deleted function" "" { target *-*-* } 189 }
45
46   std::unique_ptr<int[], B&> uba(nullptr, b);
47   std::unique_ptr<int[], D&> uda(nullptr, d);
48   uba = std::move(uda);
49 // { dg-error "use of deleted function" "" { target *-*-* } 329 }
50 }