]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2012-2022 Free Software Foundation, Inc. |
fd18c76a JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
52066eae JW |
18 | // { dg-do compile { target c++11 } } |
19 | // { dg-options "-fno-access-control" } | |
fd18c76a JW |
20 | |
21 | // libstdc++/52591 | |
22 | ||
23 | #include <deque> | |
24 | #include <memory> | |
25 | #include <type_traits> | |
26 | ||
27 | ||
9425300b JW |
28 | // Move-assignment of std::deque<T> is allowed for non-MoveAssignable T when |
29 | // the allocator type propagates. As an extension we also allow it if the | |
30 | // allocator type is known to always compare equal. | |
fd18c76a JW |
31 | |
32 | struct C | |
33 | { | |
34 | C& operator=(C&&) = delete; | |
35 | }; | |
36 | ||
37 | template<typename T> | |
38 | struct A1 : std::allocator<T> | |
39 | { | |
40 | template<typename U> struct rebind { typedef A1<U> other; }; | |
41 | ||
42 | A1() = default; | |
43 | template<typename U> A1(const A1<U>&) { } | |
44 | ||
45 | using propagate_on_container_move_assignment = std::true_type; | |
9425300b | 46 | using is_always_equal = std::false_type; |
fd18c76a JW |
47 | }; |
48 | ||
49 | void test01() | |
50 | { | |
51 | using test_type = std::deque<C, A1<C>>; | |
52 | static_assert(std::is_move_assignable<test_type>::value, | |
53 | "deque is move-assignable if allocator propagates"); | |
54 | } | |
55 | ||
56 | template<typename T> | |
57 | struct A2 : std::allocator<T> | |
58 | { | |
59 | template<typename U> struct rebind { typedef A2<U> other; }; | |
60 | ||
61 | A2() = default; | |
62 | template<typename U> A2(const A2<U>&) { } | |
63 | ||
64 | using propagate_on_container_move_assignment = std::false_type; | |
fd18c76a | 65 | |
a2b5fdcb JW |
66 | using is_always_equal = std::true_type; |
67 | }; | |
fd18c76a JW |
68 | |
69 | void test02() | |
70 | { | |
71 | using test_type = std::deque<C, A2<C>>; | |
72 | static_assert(std::is_nothrow_move_assignable<test_type>::value, | |
73 | "deque is nothrow move-assignable if allocator is always equal"); | |
74 | } |