public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61023] New: set/map move assignment doesn't move (or copy) the comparator
@ 2014-04-30 22:24 nevin at eviloverlord dot com
  2014-04-30 22:27 ` [Bug libstdc++/61023] " nevin at eviloverlord dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: nevin at eviloverlord dot com @ 2014-04-30 22:24 UTC (permalink / raw)
  To: gcc-bugs

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;
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-05-07 14:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 22:24 [Bug libstdc++/61023] New: set/map move assignment doesn't move (or copy) the comparator nevin at eviloverlord dot com
2014-04-30 22:27 ` [Bug libstdc++/61023] " nevin at eviloverlord dot com
2014-04-30 22:35 ` nevin at eviloverlord dot com
2014-05-01 21:25 ` nevin at eviloverlord dot com
2014-05-04 15:56 ` redi at gcc dot gnu.org
2014-05-06 23:50 ` ppluzhnikov at google dot com
2014-05-07 13:15 ` [Bug libstdc++/61023] [4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-05-07 14:12 ` redi at gcc dot gnu.org
2014-05-07 14:13 ` redi at gcc dot gnu.org
2014-05-07 14:16 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).