Skip to content

Commit db068c4

Browse files
committed
[libc++] Fix the rest of __gnu_cxx::hash_XXX copy construction
1 parent 70bd610 commit db068c4

File tree

5 files changed

+84
-12
lines changed

5 files changed

+84
-12
lines changed

libcxx/include/ext/hash_map

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
570570
}
571571

572572
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
573-
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(const hash_map& __u) : __table_(__u.__table_) {
574-
__table_.__rehash_unique(__u.bucket_count());
575-
insert(__u.begin(), __u.end());
576-
}
573+
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(const hash_map& __u) : __table_(__u.__table_) {}
577574

578575
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
579576
typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder

libcxx/include/ext/hash_set

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
356356
}
357357

358358
template <class _Value, class _Hash, class _Pred, class _Alloc>
359-
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(const hash_set& __u) : __table_(__u.__table_) {
360-
__table_.__rehash_unique(__u.bucket_count());
361-
insert(__u.begin(), __u.end());
362-
}
359+
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(const hash_set& __u) : __table_(__u.__table_) {}
363360

364361
template <class _Value, class _Hash, class _Pred, class _Alloc>
365362
template <class _InputIterator>
@@ -534,10 +531,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
534531
}
535532

536533
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-
}
534+
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {}
541535

542536
template <class _Value, class _Hash, class _Pred, class _Alloc>
543537
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_map<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+
}
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_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+
}
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_set>
15+
16+
int main(int, char**) {
17+
__gnu_cxx::hash_set<int> set;
18+
19+
set.insert(1);
20+
set.insert(2);
21+
22+
auto set2 = set;
23+
24+
assert(set2.size() == 2);
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)