Skip to content

Commit 5e23f8a

Browse files
authored
[libc++] Fix __gnu_cxx::hash_multimap copy construction (#160043)
1 parent 8f905c3 commit 5e23f8a

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

libcxx/include/ext/hash_map

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
787787
}
788788

789789
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
790-
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(const hash_multimap& __u) : __table_(__u.__table_) {
791-
__table_.__rehash_multi(__u.bucket_count());
792-
insert(__u.begin(), __u.end());
793-
}
790+
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(const hash_multimap& __u) : __table_(__u.__table_) {}
794791

795792
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
796793
template <class _InputIterator>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
10+
11+
// hash_multimap::hash_multimap(const hash_multimap&)
12+
13+
#include <cassert>
14+
#include <ext/hash_map>
15+
16+
int main(int, char**) {
17+
__gnu_cxx::hash_multimap<int, int> map;
18+
19+
map.insert(std::make_pair(1, 1));
20+
map.insert(std::make_pair(1, 1));
21+
22+
auto map2 = map;
23+
24+
assert(map2.size() == 2);
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)