Expand calls to insert_range

This commit is contained in:
Daniel James
2017-04-23 10:09:18 +01:00
parent b6c229e2bb
commit da835e88b8
3 changed files with 40 additions and 40 deletions

View File

@@ -4071,12 +4071,6 @@ struct table_unique : boost::unordered::detail::table<Types>
// if hash function throws, or inserting > 1 element, basic exception // if hash function throws, or inserting > 1 element, basic exception
// safety strong otherwise // safety strong otherwise
template <class InputIt> void insert_range(InputIt i, InputIt j)
{
if (i != j)
return insert_range_impl(extractor::extract(*i), i, j);
}
template <class InputIt> template <class InputIt>
void insert_range_impl(const_key_type& k, InputIt i, InputIt j) void insert_range_impl(const_key_type& k, InputIt i, InputIt j)
{ {

View File

@@ -1369,7 +1369,7 @@ unordered_map<K, T, H, P, A>::unordered_map(InputIt f, InputIt l, size_type n,
const hasher& hf, const key_equal& eql, const allocator_type& a) const hasher& hf, const key_equal& eql, const allocator_type& a)
: table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1409,7 +1409,7 @@ unordered_map<K, T, H, P, A>::unordered_map(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, eql, a) hf, eql, a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1435,7 +1435,7 @@ unordered_map<K, T, H, P, A>::unordered_map(
: table_(boost::unordered::detail::initial_size(f, l, n), hasher(), : table_(boost::unordered::detail::initial_size(f, l, n), hasher(),
key_equal(), a) key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1445,7 +1445,7 @@ unordered_map<K, T, H, P, A>::unordered_map(InputIt f, InputIt l, size_type n,
: table_( : table_(
boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1458,7 +1458,7 @@ unordered_map<K, T, H, P, A>::unordered_map(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hasher(), key_equal(), a) hasher(), key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1469,7 +1469,7 @@ unordered_map<K, T, H, P, A>::unordered_map(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, key_equal(), a) hf, key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1486,7 +1486,7 @@ unordered_map<K, T, H, P, A>& unordered_map<K, T, H, P, A>::operator=(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
this->clear(); this->clear();
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
return *this; return *this;
} }
@@ -1512,7 +1512,10 @@ template <class K, class T, class H, class P, class A>
template <class InputIt> template <class InputIt>
void unordered_map<K, T, H, P, A>::insert(InputIt first, InputIt last) void unordered_map<K, T, H, P, A>::insert(InputIt first, InputIt last)
{ {
table_.insert_range(first, last); if (first != last) {
table_.insert_range_impl(
table::extractor::extract(*first), first, last);
}
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1520,7 +1523,7 @@ template <class K, class T, class H, class P, class A>
void unordered_map<K, T, H, P, A>::insert( void unordered_map<K, T, H, P, A>::insert(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1811,7 +1814,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(InputIt f, InputIt l,
const allocator_type& a) const allocator_type& a)
: table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1852,7 +1855,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, eql, a) hf, eql, a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1878,7 +1881,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
: table_(boost::unordered::detail::initial_size(f, l, n), hasher(), : table_(boost::unordered::detail::initial_size(f, l, n), hasher(),
key_equal(), a) key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1888,7 +1891,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(InputIt f, InputIt l,
: table_( : table_(
boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1901,7 +1904,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hasher(), key_equal(), a) hasher(), key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
@@ -1912,7 +1915,7 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, key_equal(), a) hf, key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1929,7 +1932,7 @@ unordered_multimap<K, T, H, P, A>& unordered_multimap<K, T, H, P, A>::operator=(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
this->clear(); this->clear();
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
return *this; return *this;
} }
@@ -1963,7 +1966,7 @@ template <class K, class T, class H, class P, class A>
void unordered_multimap<K, T, H, P, A>::insert( void unordered_multimap<K, T, H, P, A>::insert(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif

View File

@@ -1068,7 +1068,7 @@ unordered_set<T, H, P, A>::unordered_set(InputIt f, InputIt l, size_type n,
const hasher& hf, const key_equal& eql, const allocator_type& a) const hasher& hf, const key_equal& eql, const allocator_type& a)
: table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1108,7 +1108,7 @@ unordered_set<T, H, P, A>::unordered_set(std::initializer_list<value_type> list,
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, eql, a) hf, eql, a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1133,7 +1133,7 @@ unordered_set<T, H, P, A>::unordered_set(
: table_(boost::unordered::detail::initial_size(f, l, n), hasher(), : table_(boost::unordered::detail::initial_size(f, l, n), hasher(),
key_equal(), a) key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1143,7 +1143,7 @@ unordered_set<T, H, P, A>::unordered_set(InputIt f, InputIt l, size_type n,
: table_( : table_(
boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1155,7 +1155,7 @@ unordered_set<T, H, P, A>::unordered_set(std::initializer_list<value_type> list,
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hasher(), key_equal(), a) hasher(), key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1165,7 +1165,7 @@ unordered_set<T, H, P, A>::unordered_set(std::initializer_list<value_type> list,
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, key_equal(), a) hf, key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1182,7 +1182,7 @@ unordered_set<T, H, P, A>& unordered_set<T, H, P, A>::operator=(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
this->clear(); this->clear();
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
return *this; return *this;
} }
@@ -1208,14 +1208,17 @@ template <class T, class H, class P, class A>
template <class InputIt> template <class InputIt>
void unordered_set<T, H, P, A>::insert(InputIt first, InputIt last) void unordered_set<T, H, P, A>::insert(InputIt first, InputIt last)
{ {
table_.insert_range(first, last); if (first != last) {
table_.insert_range_impl(
table::extractor::extract(*first), first, last);
}
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
void unordered_set<T, H, P, A>::insert(std::initializer_list<value_type> list) void unordered_set<T, H, P, A>::insert(std::initializer_list<value_type> list)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1445,7 +1448,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(InputIt f, InputIt l,
const allocator_type& a) const allocator_type& a)
: table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a) : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1486,7 +1489,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, eql, a) hf, eql, a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1512,7 +1515,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
: table_(boost::unordered::detail::initial_size(f, l, n), hasher(), : table_(boost::unordered::detail::initial_size(f, l, n), hasher(),
key_equal(), a) key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1522,7 +1525,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(InputIt f, InputIt l,
: table_( : table_(
boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a) boost::unordered::detail::initial_size(f, l, n), hf, key_equal(), a)
{ {
table_.insert_range(f, l); this->insert(f, l);
} }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1535,7 +1538,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hasher(), key_equal(), a) hasher(), key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
@@ -1546,7 +1549,7 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
boost::unordered::detail::initial_size(list.begin(), list.end(), n), boost::unordered::detail::initial_size(list.begin(), list.end(), n),
hf, key_equal(), a) hf, key_equal(), a)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif
@@ -1563,7 +1566,7 @@ unordered_multiset<T, H, P, A>& unordered_multiset<T, H, P, A>::operator=(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
this->clear(); this->clear();
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
return *this; return *this;
} }
@@ -1597,7 +1600,7 @@ template <class T, class H, class P, class A>
void unordered_multiset<T, H, P, A>::insert( void unordered_multiset<T, H, P, A>::insert(
std::initializer_list<value_type> list) std::initializer_list<value_type> list)
{ {
table_.insert_range(list.begin(), list.end()); this->insert(list.begin(), list.end());
} }
#endif #endif