mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Add transparent insert() overloads to unordered_[flat]_set
This commit is contained in:
@ -1477,7 +1477,22 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
template <typename T, typename Alloc, typename Key>
|
||||||
|
inline typename boost::allocator_pointer<Alloc>::type
|
||||||
|
construct_node_from_key(T*, Alloc& alloc, BOOST_FWD_REF(Key) k)
|
||||||
|
{
|
||||||
|
return construct_node(alloc, boost::forward<Key>(k));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename V, typename Alloc, typename Key>
|
||||||
|
inline typename boost::allocator_pointer<Alloc>::type
|
||||||
|
construct_node_from_key(
|
||||||
|
std::pair<T const, V>*, Alloc& alloc, BOOST_FWD_REF(Key) k)
|
||||||
|
{
|
||||||
|
return construct_node_pair(alloc, boost::forward<Key>(k));
|
||||||
|
}
|
||||||
|
} // namespace func
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2640,8 +2655,10 @@ namespace boost {
|
|||||||
} else {
|
} else {
|
||||||
node_allocator_type alloc = node_alloc();
|
node_allocator_type alloc = node_alloc();
|
||||||
|
|
||||||
node_tmp tmp(
|
value_type* dispatch = BOOST_NULLPTR;
|
||||||
detail::func::construct_node_pair(alloc, boost::forward<Key>(k)),
|
|
||||||
|
node_tmp tmp(detail::func::construct_node_from_key(
|
||||||
|
dispatch, alloc, boost::forward<Key>(k)),
|
||||||
alloc);
|
alloc);
|
||||||
|
|
||||||
if (size_ + 1 > max_load_) {
|
if (size_ + 1 > max_load_) {
|
||||||
@ -2660,7 +2677,7 @@ namespace boost {
|
|||||||
template <typename Key>
|
template <typename Key>
|
||||||
iterator try_emplace_hint_unique(c_iterator hint, BOOST_FWD_REF(Key) k)
|
iterator try_emplace_hint_unique(c_iterator hint, BOOST_FWD_REF(Key) k)
|
||||||
{
|
{
|
||||||
if (hint.p && this->key_eq()(hint->first, k)) {
|
if (hint.p && this->key_eq()(extractor::extract(*hint), k)) {
|
||||||
return iterator(hint.p, hint.itb);
|
return iterator(hint.p, hint.itb);
|
||||||
} else {
|
} else {
|
||||||
return try_emplace_unique(k).first;
|
return try_emplace_unique(k).first;
|
||||||
|
@ -231,6 +231,15 @@ namespace boost {
|
|||||||
return table_.insert(std::move(value));
|
return table_.insert(std::move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class K>
|
||||||
|
BOOST_FORCEINLINE typename std::enable_if<
|
||||||
|
detail::transparent_non_iterable<K, unordered_flat_set>::value,
|
||||||
|
std::pair<iterator, bool> >::type
|
||||||
|
insert(K&& k)
|
||||||
|
{
|
||||||
|
return table_.try_emplace(std::forward<K>(k));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_FORCEINLINE iterator insert(const_iterator, value_type const& value)
|
BOOST_FORCEINLINE iterator insert(const_iterator, value_type const& value)
|
||||||
{
|
{
|
||||||
return table_.insert(value).first;
|
return table_.insert(value).first;
|
||||||
@ -241,6 +250,15 @@ namespace boost {
|
|||||||
return table_.insert(std::move(value)).first;
|
return table_.insert(std::move(value)).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class K>
|
||||||
|
BOOST_FORCEINLINE typename std::enable_if<
|
||||||
|
detail::transparent_non_iterable<K, unordered_flat_set>::value,
|
||||||
|
iterator>::type
|
||||||
|
insert(const_iterator, K&& k)
|
||||||
|
{
|
||||||
|
return table_.try_emplace(std::forward<K>(k)).first;
|
||||||
|
}
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
void insert(InputIterator first, InputIterator last)
|
void insert(InputIterator first, InputIterator last)
|
||||||
{
|
{
|
||||||
|
@ -390,6 +390,15 @@ namespace boost {
|
|||||||
return this->emplace(boost::move(x));
|
return this->emplace(boost::move(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Key>
|
||||||
|
typename boost::enable_if_c<
|
||||||
|
detail::transparent_non_iterable<Key, unordered_set>::value,
|
||||||
|
std::pair<iterator, bool> >::type
|
||||||
|
insert(BOOST_FWD_REF(Key) k)
|
||||||
|
{
|
||||||
|
return table_.try_emplace_unique(boost::forward<Key>(k));
|
||||||
|
}
|
||||||
|
|
||||||
iterator insert(const_iterator hint, value_type const& x)
|
iterator insert(const_iterator hint, value_type const& x)
|
||||||
{
|
{
|
||||||
return this->emplace_hint(hint, x);
|
return this->emplace_hint(hint, x);
|
||||||
@ -400,6 +409,15 @@ namespace boost {
|
|||||||
return this->emplace_hint(hint, boost::move(x));
|
return this->emplace_hint(hint, boost::move(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Key>
|
||||||
|
typename boost::enable_if_c<
|
||||||
|
detail::transparent_non_iterable<Key, unordered_set>::value,
|
||||||
|
iterator>::type
|
||||||
|
insert(const_iterator hint, BOOST_FWD_REF(Key) k)
|
||||||
|
{
|
||||||
|
return table_.try_emplace_hint_unique(hint, boost::forward<Key>(k));
|
||||||
|
}
|
||||||
|
|
||||||
template <class InputIt> void insert(InputIt, InputIt);
|
template <class InputIt> void insert(InputIt, InputIt);
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
|
Reference in New Issue
Block a user