]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/unique_ptr/assign/cv_qual.cc
1 // { dg-options "-std=gnu++11" }
4 // Copyright (C) 2012-2016 Free Software Foundation, Inc.
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)
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.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 20.7.1 Class template unique_ptr [unique.ptr]
25 struct A
{ virtual ~A() = default; };
29 // Assignment from objects with different cv-qualification
34 std::unique_ptr
<A
> upA
;
36 std::unique_ptr
<const A
> cA
;
38 std::unique_ptr
<volatile A
> vA
;
40 std::unique_ptr
<const volatile A
> cvA
;
47 std::unique_ptr
<B
> upB
;
49 std::unique_ptr
<const A
> cA
;
51 std::unique_ptr
<volatile A
> vA
;
53 std::unique_ptr
<const volatile A
> cvA
;
60 std::unique_ptr
<A
[]> upA
;
62 std::unique_ptr
<const A
[]> cA
;
64 std::unique_ptr
<volatile A
[]> vA
;
66 std::unique_ptr
<const volatile A
[]> cvA
;
70 struct A_pointer
{ operator A
*() const { return nullptr; } };
77 deleter(const deleter
<U
>) { }
79 void operator()(T
) const { }
85 // Disallow conversions from incompatible deleter
86 std::unique_ptr
<B
[], deleter
<A_pointer
>> p
;
87 std::unique_ptr
<A
[], deleter
<A
*>> upA
;
88 upA
= std::move(p
); // { dg-error "no match" }
89 // { dg-error "no type" "" { target *-*-* } 537 }
90 // { dg-error "no matching function" "" { target *-*-* } 614 }