Changeset View
Changeset View
Standalone View
Standalone View
source/blender/functions/FN_generic_pointer.hh
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | template<typename T> T *get() const | ||||
| return static_cast<T *>(data_); | return static_cast<T *>(data_); | ||||
| } | } | ||||
| template<typename T> bool is_type() const | template<typename T> bool is_type() const | ||||
| { | { | ||||
| return type_ != nullptr && type_->is<T>(); | return type_ != nullptr && type_->is<T>(); | ||||
| } | } | ||||
| template<typename T> T relocate_out() | |||||
| { | |||||
| BLI_assert(this->is_type<T>()); | |||||
| T value; | |||||
| type_->relocate_to_initialized(data_, &value); | |||||
| data_ = nullptr; | |||||
| type_ = nullptr; | |||||
| return value; | |||||
| } | |||||
| void destruct() | void destruct() | ||||
| { | { | ||||
| BLI_assert(data_ != nullptr); | BLI_assert(data_ != nullptr); | ||||
| type_->destruct(data_); | type_->destruct(data_); | ||||
| } | } | ||||
| }; | }; | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||