]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/54276.cc
1 // Copyright (C) 2012-2016 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
19 // { dg-options "-std=gnu++11" }
22 #include <unordered_map>
23 #include <testsuite_hooks.h>
25 bool test
__attribute__((unused
)) = true;
30 static std::set
<const A
*> destroyed
;
33 { destroyed
.erase(this); }
37 { destroyed
.erase(this); }
40 { destroyed
.insert(this); }
43 operator==(const A
& other
) const
45 VERIFY( destroyed
.find(this) == destroyed
.end() );
46 VERIFY( destroyed
.find(&other
) == destroyed
.end() );
51 std::set
<const A
*> A::destroyed
;
55 std::size_t operator()(const A
& a
) const
57 VERIFY( A::destroyed
.find(&a
) == A::destroyed
.end() );
64 typedef std::unordered_multimap
<A
, A
, hasher
> UMMap
;
72 VERIFY( map
.size() == 2 );
73 std::size_t bkt
= map
.bucket(a
);
74 VERIFY( map
.bucket_size(bkt
) == 2 );
76 VERIFY( map
.erase( map
.begin(bkt
)->first
) == 2 );
81 typedef std::unordered_multimap
<A
, A
, hasher
> UMMap
;
89 VERIFY( map
.size() == 2 );
90 std::size_t bkt
= map
.bucket(a
);
91 VERIFY( map
.bucket_size(bkt
) == 2 );
93 VERIFY( map
.erase( map
.begin(bkt
)->second
) == 2 );