mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Simplify range-based insert() so it doesn't eagerly rehash so that insert_tests pass
This commit is contained in:
@ -92,24 +92,8 @@ namespace boost {
|
|||||||
return table_.insert(std::move(value)).first;
|
return table_.insert(std::move(value)).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ForwardIterator>
|
|
||||||
typename std::enable_if<
|
|
||||||
std::is_base_of<std::forward_iterator_tag, ForwardIterator>::value,
|
|
||||||
void>::type
|
|
||||||
insert(ForwardIterator first, ForwardIterator last)
|
|
||||||
{
|
|
||||||
auto const len = std::distance(first, last);
|
|
||||||
table_.reserve(len);
|
|
||||||
for (auto pos = first; pos != last; ++pos) {
|
|
||||||
table_.insert(*pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
typename std::enable_if<
|
void insert(InputIterator first, InputIterator last)
|
||||||
!std::is_base_of<std::forward_iterator_tag, InputIterator>::value,
|
|
||||||
void>::type
|
|
||||||
insert(InputIterator first, InputIterator last)
|
|
||||||
{
|
{
|
||||||
for (auto pos = first; pos != last; ++pos) {
|
for (auto pos = first; pos != last; ++pos) {
|
||||||
table_.insert(*pos);
|
table_.insert(*pos);
|
||||||
|
@ -91,24 +91,8 @@ namespace boost {
|
|||||||
return table_.insert(std::move(value)).first;
|
return table_.insert(std::move(value)).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ForwardIterator>
|
|
||||||
typename std::enable_if<
|
|
||||||
std::is_base_of<std::forward_iterator_tag, ForwardIterator>::value,
|
|
||||||
void>::type
|
|
||||||
insert(ForwardIterator first, ForwardIterator last)
|
|
||||||
{
|
|
||||||
auto const len = std::distance(first, last);
|
|
||||||
table_.reserve(len);
|
|
||||||
for (auto pos = first; pos != last; ++pos) {
|
|
||||||
table_.insert(*pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
typename std::enable_if<
|
void insert(InputIterator first, InputIterator last)
|
||||||
!std::is_base_of<std::forward_iterator_tag, InputIterator>::value,
|
|
||||||
void>::type
|
|
||||||
insert(InputIterator first, InputIterator last)
|
|
||||||
{
|
{
|
||||||
for (auto pos = first; pos != last; ++pos) {
|
for (auto pos = first; pos != last; ++pos) {
|
||||||
table_.insert(*pos);
|
table_.insert(*pos);
|
||||||
|
Reference in New Issue
Block a user