Skip to content

Commit fca3277

Browse files
philnik777mahesh-attarde
authored andcommitted
[libc++] Fix __gnu_cxx::hash_multiset copy construction (llvm#160466)
1 parent 6739046 commit fca3277

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

libcxx/include/ext/hash_set

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
534534
}
535535

536536
template <class _Value, class _Hash, class _Pred, class _Alloc>
537-
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {
538-
__table_.__rehash_multi(__u.bucket_count());
539-
insert(__u.begin(), __u.end());
540-
}
537+
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {}
541538

542539
template <class _Value, class _Hash, class _Pred, class _Alloc>
543540
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_multiset::hash_multiset(const hash_multiset&)
12+
13+
#include <cassert>
14+
#include <ext/hash_set>
15+
16+
int main(int, char**) {
17+
__gnu_cxx::hash_multiset<int> set;
18+
19+
set.insert(1);
20+
set.insert(1);
21+
22+
auto set2 = set;
23+
24+
assert(set2.size() == 2);
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)