Update insert(Iterator, Iterator) overloads to use emplace internally instead of insert()'ing

This commit is contained in:
Christian Mazakas
2022-10-21 11:24:34 -07:00
parent ad1e3a49a5
commit e0b680ac29
4 changed files with 35 additions and 3 deletions

View File

@@ -1256,7 +1256,14 @@ public:
template<typename... Args>
BOOST_FORCEINLINE std::pair<iterator,bool> emplace(Args&&... args)
{
return emplace_impl(init_type(std::forward<Args>(args)...));
using emplace_type = typename std::conditional<
std::is_constructible<
init_type, Args...
>::value,
init_type,
value_type
>::type;
return emplace_impl(emplace_type(std::forward<Args>(args)...));
}
template<typename Key,typename... Args>

View File

@@ -242,7 +242,7 @@ namespace boost {
void insert(InputIterator first, InputIterator last)
{
for (auto pos = first; pos != last; ++pos) {
table_.insert(*pos);
table_.emplace(*pos);
}
}

View File

@@ -222,7 +222,7 @@ namespace boost {
void insert(InputIterator first, InputIterator last)
{
for (auto pos = first; pos != last; ++pos) {
table_.insert(*pos);
table_.emplace(*pos);
}
}