| 1 |
// { dg-do run { target c++11 } } |
| 2 |
|
| 3 |
// PR libstdc++/103501 |
| 4 |
|
| 5 |
#include <set> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
#include <testsuite_allocator.h> |
| 8 |
|
| 9 |
struct X |
| 10 |
{ |
| 11 |
int i; |
| 12 |
|
| 13 |
X(int i) : i(i) { } |
| 14 |
X(const X& x) noexcept : i(x.i) { } |
| 15 |
X(X&& x) noexcept : i(x.i) { x.i = -1; } |
| 16 |
|
| 17 |
bool operator<(const X& rhs) const { return i < rhs.i; } |
| 18 |
}; |
| 19 |
|
| 20 |
int main() |
| 21 |
{ |
| 22 |
using Alloc = __gnu_test::uneq_allocator<X>; |
| 23 |
std::set<X, std::less<X>, Alloc> s1{ {1, 2, 3}, Alloc(1)}; |
| 24 |
std::set<X, std::less<X>, Alloc> s2{ std::move(s1), Alloc(2) }; |
| 25 |
const X* prev = nullptr; |
| 26 |
for (const X& x : s1) |
| 27 |
{ |
| 28 |
if (prev) |
| 29 |
VERIFY( *prev < x ); |
| 30 |
prev = &x; |
| 31 |
} |
| 32 |
} |