updated robin_hood.h to v3.11.5

This commit is contained in:
aristocratos 2022-04-06 13:03:49 +02:00
parent 9373d9d702
commit 87579be5d6
1 changed files with 28 additions and 13 deletions

View File

@ -36,7 +36,7 @@
// see https://semver.org/
#define ROBIN_HOOD_VERSION_MAJOR 3 // for incompatible API changes
#define ROBIN_HOOD_VERSION_MINOR 11 // for adding functionality in a backwards-compatible manner
#define ROBIN_HOOD_VERSION_PATCH 3 // for backwards-compatible bug fixes
#define ROBIN_HOOD_VERSION_PATCH 5 // for backwards-compatible bug fixes
#include <algorithm>
#include <cstdlib>
@ -1820,6 +1820,12 @@ public:
InsertionState::key_found != idxAndState.second);
}
template <typename... Args>
iterator emplace_hint(const_iterator position, Args&&... args) {
(void)position;
return emplace(std::forward<Args>(args)...).first;
}
template <typename... Args>
std::pair<iterator, bool> try_emplace(const key_type& key, Args&&... args) {
return try_emplace_impl(key, std::forward<Args>(args)...);
@ -1831,16 +1837,15 @@ public:
}
template <typename... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, const key_type& key,
Args&&... args) {
iterator try_emplace(const_iterator hint, const key_type& key, Args&&... args) {
(void)hint;
return try_emplace_impl(key, std::forward<Args>(args)...);
return try_emplace_impl(key, std::forward<Args>(args)...).first;
}
template <typename... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
iterator try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
(void)hint;
return try_emplace_impl(std::move(key), std::forward<Args>(args)...);
return try_emplace_impl(std::move(key), std::forward<Args>(args)...).first;
}
template <typename Mapped>
@ -1854,16 +1859,15 @@ public:
}
template <typename Mapped>
std::pair<iterator, bool> insert_or_assign(const_iterator hint, const key_type& key,
Mapped&& obj) {
iterator insert_or_assign(const_iterator hint, const key_type& key, Mapped&& obj) {
(void)hint;
return insertOrAssignImpl(key, std::forward<Mapped>(obj));
return insertOrAssignImpl(key, std::forward<Mapped>(obj)).first;
}
template <typename Mapped>
std::pair<iterator, bool> insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
iterator insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
(void)hint;
return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj));
return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj)).first;
}
std::pair<iterator, bool> insert(const value_type& keyval) {
@ -1871,10 +1875,20 @@ public:
return emplace(keyval);
}
iterator insert(const_iterator hint, const value_type& keyval) {
(void)hint;
return emplace(keyval).first;
}
std::pair<iterator, bool> insert(value_type&& keyval) {
return emplace(std::move(keyval));
}
iterator insert(const_iterator hint, value_type&& keyval) {
(void)hint;
return emplace(std::move(keyval)).first;
}
// Returns 1 if key is found, 0 otherwise.
size_t count(const key_type& key) const { // NOLINT(modernize-use-nodiscard)
ROBIN_HOOD_TRACE(this)
@ -2308,13 +2322,14 @@ private:
auto const numElementsWithBuffer = calcNumElementsWithBuffer(max_elements);
// calloc also zeroes everything
// malloc & zero mInfo. Faster than calloc everything.
auto const numBytesTotal = calcNumBytesTotal(numElementsWithBuffer);
ROBIN_HOOD_LOG("std::calloc " << numBytesTotal << " = calcNumBytesTotal("
<< numElementsWithBuffer << ")")
mKeyVals = reinterpret_cast<Node*>(
detail::assertNotNull<std::bad_alloc>(std::calloc(1, numBytesTotal)));
detail::assertNotNull<std::bad_alloc>(std::malloc(numBytesTotal)));
mInfo = reinterpret_cast<uint8_t*>(mKeyVals + numElementsWithBuffer);
std::memset(mInfo, 0, numBytesTotal - numElementsWithBuffer * sizeof(Node));
// set sentinel
mInfo[numElementsWithBuffer] = 1;