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