Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_map / cons / 81891.cc
blob69f400458b70c2847f0ee6c58ed0a10a74734d25
1 // Copyright (C) 2017-2025 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
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/>.
18 // { dg-do run { target c++11 } }
20 #include <unordered_map>
21 #include <testsuite_hooks.h>
22 #include <testsuite_allocator.h>
24 struct fails_on_copy {
25 fails_on_copy() = default;
26 fails_on_copy(const fails_on_copy&) { throw 0; };
29 using value_type = std::pair<const int, fails_on_copy>;
31 void
32 test01()
34 value_type p;
35 try
37 std::unordered_map<int, fails_on_copy> umap(&p, &p + 1);
39 catch(...)
40 { }
43 void
44 test02()
46 using Alloc = __gnu_test::tracker_allocator<value_type>;
47 using std::hash;
48 using std::equal_to;
50 value_type p;
51 try
53 std::unordered_map<int, fails_on_copy, hash<int>, equal_to<int>, Alloc>
54 umap(&p, &p + 1);
56 catch(...)
57 { }
59 using counter = __gnu_test::tracker_allocator_counter;
60 VERIFY(counter::get_allocation_count() == counter::get_deallocation_count());
63 int
64 main()
66 test01();
67 test02();