Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_stack.hh
| Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | public: | ||||
| void push(const T &value) | void push(const T &value) | ||||
| { | { | ||||
| this->push_as(value); | this->push_as(value); | ||||
| } | } | ||||
| void push(T &&value) | void push(T &&value) | ||||
| { | { | ||||
| this->push_as(std::move(value)); | this->push_as(std::move(value)); | ||||
| } | } | ||||
| template<typename ForwardT> void push_as(ForwardT &&value) | /* This is similar to `std::stack::emplace`. */ | ||||
| template<typename... ForwardT> void push_as(ForwardT &&... value) | |||||
| { | { | ||||
| if (top_ == top_chunk_->capacity_end) { | if (top_ == top_chunk_->capacity_end) { | ||||
| this->activate_next_chunk(1); | this->activate_next_chunk(1); | ||||
| } | } | ||||
| try { | try { | ||||
| new (top_) T(std::forward<ForwardT>(value)); | new (top_) T(std::forward<ForwardT>(value)...); | ||||
| top_++; | top_++; | ||||
| size_++; | size_++; | ||||
| } | } | ||||
| catch (...) { | catch (...) { | ||||
| this->move_top_pointer_back_to_below_chunk(); | this->move_top_pointer_back_to_below_chunk(); | ||||
| throw; | throw; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines | |||||