1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2012 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <unordered_set>
21 #include <testsuite_hooks.h>
26 num(int n) : value(n) {}
27 num(num const&) = default;
28 num& operator=(num const&) = default;
29 num(num&& o) : value(o.value)
31 num& operator=(num&& o)
44 size_t operator()(num const& a) const
50 static bool _S_called_on_moved_instance;
51 bool operator()(num const& a, num const& b) const
53 if (a.value == -1 || b.value == -1)
54 _S_called_on_moved_instance = true;
55 return a.value == b.value;
59 bool num_equal::_S_called_on_moved_instance = false;
64 bool test __attribute__((unused)) = true;
66 std::unordered_multiset<num, num_hash, num_equal> mset;
71 VERIFY( mset.size() == 4 );
72 auto iter = mset.cbegin();
73 int x0 = (iter++)->value;
74 int x1 = (iter++)->value;
75 int x2 = (iter++)->value;
76 int x3 = (iter++)->value;
77 VERIFY( iter == mset.cend() );
78 VERIFY( (x0 == 1 && x1 == 1 && x2 == 2 && x3 == 2)
79 || (x0 == 2 && x1 == 2 && x2 == 1 && x3 == 1) );
80 VERIFY( !num_equal::_S_called_on_moved_instance );