This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61023] New: set/map move assignment doesn't move (or copy) the comparator
- From: "nevin at eviloverlord dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 30 Apr 2014 22:24:45 +0000
- Subject: [Bug libstdc++/61023] New: set/map move assignment doesn't move (or copy) the comparator
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61023
Bug ID: 61023
Summary: set/map move assignment doesn't move (or copy) the
comparator
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: nevin at eviloverlord dot com
If you have a stateful comparator, set/map move assignment does not move (or
copy, for that matter) the comparator.
Test case:
struct Compare
{
Compare(bool b) : b_(b) {}
bool operator()(int l, int r) const
{ return b_ ? r < l : l < r; }
bool b_;
};
int main()
{
typedef std::set<int, Compare> S;
S s(Compare(false));
s.insert(2);
s.insert(3);
assert(*s.begin() == 2);
s.clear();
S st(Compare(true));
s = std::move(st); // move assignment
s.insert(2);
s.insert(3);
assert(*s.begin() == 3); // fails
return 0;
}