diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-11 11:48:52 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-11 11:48:52 +0300 |
commit | f028760b83c340b802adea7bab019ca14d95bad4 (patch) | |
tree | 1bed6e156bbb4d3c37939a4fbc842d5b014dccbc /source/blender/blenlib/BLI_map.hh | |
parent | 3f648f5b423347fa31e60cf52701a10862a157f1 (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.hh | 27 |
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()}; |