| 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 Y |
| 10 | { |
| 11 | int i; |
| 12 | |
| 13 | Y(int i) : i(i) { } |
| 14 | Y(const Y& y) noexcept : i(y.i) { } |
| 15 | Y(Y&& y) noexcept : i(y.i) { y.i = -y.i; } |
| 16 | |
| 17 | bool operator<(const Y& rhs) const { return i < rhs.i; } |
| 18 | }; |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | using Alloc = __gnu_test::uneq_allocator<Y>; |
| 23 | std::multiset<Y, std::less<Y>, Alloc> s1{ {1, 2, 3}, Alloc(1)}; |
| 24 | std::multiset<Y, std::less<Y>, Alloc> s2{ std::move(s1), Alloc(2) }; |
| 25 | const Y* prev = nullptr; |
| 26 | for (const Y& y : s1) |
| 27 | { |
| 28 | if (prev) |
| 29 | VERIFY( !(y < *prev) ); |
| 30 | prev = &y; |
| 31 | } |
| 32 | } |