Simplify range-based insert() so it doesn't eagerly rehash so that insert_tests pass

This commit is contained in:
Christian Mazakas
2022-09-29 11:18:59 -07:00
parent ac3520791e
commit 8f29a32a33
2 changed files with 2 additions and 34 deletions

View File

@ -92,24 +92,8 @@ namespace boost {
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>
typename std::enable_if<
!std::is_base_of<std::forward_iterator_tag, InputIterator>::value,
void>::type
insert(InputIterator first, InputIterator last)
void insert(InputIterator first, InputIterator last)
{
for (auto pos = first; pos != last; ++pos) {
table_.insert(*pos);

View File

@ -91,24 +91,8 @@ namespace boost {
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>
typename std::enable_if<
!std::is_base_of<std::forward_iterator_tag, InputIterator>::value,
void>::type
insert(InputIterator first, InputIterator last)
void insert(InputIterator first, InputIterator last)
{
for (auto pos = first; pos != last; ++pos) {
table_.insert(*pos);