// Copyright (C) 2012-2019 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
// .
// { dg-do compile { target c++11 } }
// libstdc++/52591
#include
#include
#include
// Move-assignment of std::vector is allowed for non-MoveAssignable T when
// the allocator type propagates. As an extension we also allow it if the
// allocator type is known to always compare equal.
struct C
{
C& operator=(C&&) = delete;
};
void test01()
{
std::vector a;
a = std::vector();
}
template
struct A1 : std::allocator
{
template struct rebind { typedef A1 other; };
A1() = default;
template A1(const A1&) { }
using propagate_on_container_move_assignment = std::true_type;
using is_always_equal = std::false_type;
};
void test02()
{
using test_type = std::vector>;
static_assert(std::is_nothrow_move_assignable::value,
"vector is nothrow move-assignable if allocator propagates");
}
template
struct A2 : std::allocator
{
template struct rebind { typedef A1 other; };
A2() = default;
template A2(const A2&) { }
using propagate_on_container_move_assignment = std::false_type;
using is_always_equal = std::true_type;
};
void test03()
{
using test_type = std::vector>;
static_assert(std::is_nothrow_move_assignable::value,
"vector is nothrow move-assignable if allocator is always equal");
}