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-06-11 11:48:52 +0300
committerJacques Lucke <jacques@blender.org>2020-06-11 11:48:52 +0300
commitf028760b83c340b802adea7bab019ca14d95bad4 (patch)
tree1bed6e156bbb4d3c37939a4fbc842d5b014dccbc /source/blender/blenlib/BLI_map.hh
parent3f648f5b423347fa31e60cf52701a10862a157f1 (diff)
BLI: make Map::Item and Map::MutableItem more accessible
This makes it easier to write range-for loops over all items in the map without using auto.
Diffstat (limited to 'source/blender/blenlib/BLI_map.hh')
-rw-r--r--source/blender/blenlib/BLI_map.hh27
1 files changed, 16 insertions, 11 deletions
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 9737367ebca..48cbcb4e3e9 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -745,6 +745,21 @@ class Map {
}
};
+ struct Item {
+ const Key &key;
+ const Value &value;
+ };
+
+ struct MutableItem {
+ const Key &key;
+ Value &value;
+
+ operator Item() const
+ {
+ return Item{key, value};
+ }
+ };
+
class ItemIterator final : public BaseIterator<ItemIterator> {
public:
ItemIterator(const Slot *slots, uint32_t total_slots, uint32_t current_slot)
@@ -752,11 +767,6 @@ class Map {
{
}
- struct Item {
- const Key &key;
- const Value &value;
- };
-
Item operator*() const
{
const Slot &slot = this->current_slot();
@@ -771,12 +781,7 @@ class Map {
{
}
- struct Item {
- const Key &key;
- Value &value;
- };
-
- Item operator*() const
+ MutableItem operator*() const
{
Slot &slot = this->current_slot();
return {*slot.key(), *slot.value()};