diff options
author | Jacques Lucke <mail@jlucke.com> | 2020-02-10 15:54:57 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2020-02-10 16:09:01 +0300 |
commit | 68cc982dcb7c1063a96f7ec9b7ccb95da4919d6b (patch) | |
tree | 9d2076363b54cb6b6da96064453ac3499a5f65c8 /source/blender/blenlib/BLI_stack_cxx.h | |
parent | 76208a5670bc9d70f99f22a3c49463959461b5c1 (diff) |
BLI: improve various C++ data structures
The changes come from the `functions` branch, where I'm using
these structures a lot.
This also includes a new `BLI::Optional<T>` type, which is similar
to `std::Optional<T>` which can be used when Blender starts using
C++17.
Diffstat (limited to 'source/blender/blenlib/BLI_stack_cxx.h')
-rw-r--r-- | source/blender/blenlib/BLI_stack_cxx.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_stack_cxx.h b/source/blender/blenlib/BLI_stack_cxx.h index 7915acadfac..a26318a3dcb 100644 --- a/source/blender/blenlib/BLI_stack_cxx.h +++ b/source/blender/blenlib/BLI_stack_cxx.h @@ -58,7 +58,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class St /** * Return true when the stack is empty, otherwise false. */ - bool empty() const + bool is_empty() const { return this->size() == 0; } @@ -76,6 +76,11 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class St m_elements.append(std::move(value)); } + void push_multiple(ArrayRef<T> values) + { + m_elements.extend(values); + } + /** * Remove the element from the top of the stack and return it. * This will assert when the stack is empty. @@ -91,7 +96,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class St */ T &peek() { - BLI_assert(!this->empty()); + BLI_assert(!this->is_empty()); return m_elements[this->size() - 1]; } |