_M_move_data(__x, true_type());
else
{
+ constexpr bool __move = !__move_if_noexcept_cond<value_type>::value;
_Alloc_node __an(*this);
- _M_root() =
- _M_copy<!__move_if_noexcept_cond<value_type>::value>(__x, __an);
+ _M_root() = _M_copy<__move>(__x, __an);
+ if _GLIBCXX17_CONSTEXPR (__move)
+ __x.clear();
}
}
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
- VERIFY( v1[1].empty() );
+ VERIFY( v1.empty() );
VERIFY( v2[1] == str );
}
VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(2 == v2.get_allocator().get_personality());
- VERIFY( v1.begin()->second.empty() );
+ VERIFY( v1.empty() );
VERIFY( v2.begin()->second == str );
}
--- /dev/null
+// { dg-do run { target c++11 } }
+
+// PR libstdc++/103501
+
+#include <set>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+struct Y
+{
+ int i;
+
+ Y(int i) : i(i) { }
+ Y(const Y& y) noexcept : i(y.i) { }
+ Y(Y&& y) noexcept : i(y.i) { y.i = -y.i; }
+
+ bool operator<(const Y& rhs) const { return i < rhs.i; }
+};
+
+int main()
+{
+ using Alloc = __gnu_test::uneq_allocator<Y>;
+ std::multiset<Y, std::less<Y>, Alloc> s1{ {1, 2, 3}, Alloc(1)};
+ std::multiset<Y, std::less<Y>, Alloc> s2{ std::move(s1), Alloc(2) };
+ const Y* prev = nullptr;
+ for (const Y& y : s1)
+ {
+ if (prev)
+ VERIFY( !(y < *prev) );
+ prev = &y;
+ }
+}
--- /dev/null
+// { dg-do run { target c++11 } }
+
+// PR libstdc++/103501
+
+#include <set>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+struct X
+{
+ int i;
+
+ X(int i) : i(i) { }
+ X(const X& x) noexcept : i(x.i) { }
+ X(X&& x) noexcept : i(x.i) { x.i = -1; }
+
+ bool operator<(const X& rhs) const { return i < rhs.i; }
+};
+
+int main()
+{
+ using Alloc = __gnu_test::uneq_allocator<X>;
+ std::set<X, std::less<X>, Alloc> s1{ {1, 2, 3}, Alloc(1)};
+ std::set<X, std::less<X>, Alloc> s2{ std::move(s1), Alloc(2) };
+ const X* prev = nullptr;
+ for (const X& x : s1)
+ {
+ if (prev)
+ VERIFY( *prev < x );
+ prev = &x;
+ }
+}