[Bf-blender-cvs] [73378c2ba2d] master: BLI: improve Map.add_new
Jacques Lucke
noreply at git.blender.org
Wed Oct 28 14:00:56 CET 2020
Commit: 73378c2ba2d5845c0023077f4ebc32b78f5aa625
Author: Jacques Lucke
Date: Wed Oct 28 13:57:46 2020 +0100
Branches: master
https://developer.blender.org/rB73378c2ba2d5845c0023077f4ebc32b78f5aa625
BLI: improve Map.add_new
Now it is possible to use Map.add_new_as which supports different types
for the key and value.
===================================================================
M source/blender/blenlib/BLI_map.hh
===================================================================
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));
}
/**
More information about the Bf-blender-cvs
mailing list