Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-10-28 15:57:46 +0300
committerJacques Lucke <jacques@blender.org>2020-10-28 15:57:53 +0300
commit73378c2ba2d5845c0023077f4ebc32b78f5aa625 (patch)
treeee1175c67ad4c1e3517de8fef0c51f7c686403b6 /source/blender/blenlib/BLI_map.hh
parent322b6ac52bdc4d3f5082d46412f475663e29a1d9 (diff)
BLI: improve Map.add_new
Now it is possible to use Map.add_new_as which supports different types for the key and value.
Diffstat (limited to 'source/blender/blenlib/BLI_map.hh')
-rw-r--r--source/blender/blenlib/BLI_map.hh14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 08fe1a3cdbc..ee20cb40ade 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -230,19 +230,25 @@ class Map {
*/
void add_new(const Key &key, const Value &value)
{
- this->add_new__impl(key, value, hash_(key));
+ this->add_new_as(key, value);
}
void add_new(const Key &key, Value &&value)
{
- this->add_new__impl(key, std::move(value), hash_(key));
+ this->add_new_as(key, std::move(value));
}
void add_new(Key &&key, const Value &value)
{
- this->add_new__impl(std::move(key), value, hash_(key));
+ this->add_new_as(std::move(key), value);
}
void add_new(Key &&key, Value &&value)
{
- this->add_new__impl(std::move(key), std::move(value), hash_(key));
+ this->add_new_as(std::move(key), std::move(value));
+ }
+ template<typename ForwardKey, typename ForwardValue>
+ void add_new_as(ForwardKey &&key, ForwardValue &&value)
+ {
+ this->add_new__impl(
+ std::forward<ForwardKey>(key), std::forward<ForwardValue>(value), hash_(key));
}
/**