You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/04/24 18:08:36 UTC
[2/2] mesos git commit: Improved support for move-only types in
`hashmap`.
Improved support for move-only types in `hashmap`.
While it was already possible to create a `hashmap` over move-only
values, we still performed a copy in `put`, making it hard to
dynamically add elements with the expected stout semantics.
This patch relaxes the requirements on the value argument to `put` so
that instead of copyable we now only require move-constructible types.
Review: https://reviews.apache.org/r/66608/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b95d68d6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b95d68d6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b95d68d6
Branch: refs/heads/master
Commit: b95d68d632caef49c9bba9e57493d2d853df0a87
Parents: ac6b383
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Tue Apr 24 20:02:09 2018 +0200
Committer: Benjamin Bannier <bb...@apache.org>
Committed: Tue Apr 24 20:02:09 2018 +0200
----------------------------------------------------------------------
3rdparty/stout/include/stout/hashmap.hpp | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b95d68d6/3rdparty/stout/include/stout/hashmap.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/hashmap.hpp b/3rdparty/stout/include/stout/hashmap.hpp
index 91085b8..698fa0f 100644
--- a/3rdparty/stout/include/stout/hashmap.hpp
+++ b/3rdparty/stout/include/stout/hashmap.hpp
@@ -101,6 +101,15 @@ public:
// Inserts a key, value pair into the map replacing an old value
// if the key is already present.
+ void put(const Key& key, Value&& value)
+ {
+ std::unordered_map<Key, Value, Hash, Equal>::erase(key);
+ std::unordered_map<Key, Value, Hash, Equal>::insert(
+ std::pair<Key, Value>(key, std::move(value)));
+ }
+
+ // Inserts a key, value pair into the map replacing an old value
+ // if the key is already present.
void put(const Key& key, const Value& value)
{
std::unordered_map<Key, Value, Hash, Equal>::erase(key);