[Bf-blender-cvs] [2b0041e4dde] functions: new Optional.set_new methods
Jacques Lucke
noreply at git.blender.org
Sat Jan 18 20:17:57 CET 2020
Commit: 2b0041e4dde2dfb12aaa6da5b1ac56a84e5590eb
Author: Jacques Lucke
Date: Sat Jan 18 19:58:28 2020 +0100
Branches: functions
https://developer.blender.org/rB2b0041e4dde2dfb12aaa6da5b1ac56a84e5590eb
new Optional.set_new methods
===================================================================
M source/blender/blenlib/BLI_optional.h
===================================================================
diff --git a/source/blender/blenlib/BLI_optional.h b/source/blender/blenlib/BLI_optional.h
index 92e64996ede..8429cddc710 100644
--- a/source/blender/blenlib/BLI_optional.h
+++ b/source/blender/blenlib/BLI_optional.h
@@ -146,6 +146,20 @@ template<typename T> class Optional {
}
}
+ void set_new(const T &value)
+ {
+ BLI_assert(!m_set);
+ new (this->value_ptr()) T(value);
+ m_set = true;
+ }
+
+ void set_new(T &&value)
+ {
+ BLI_assert(!m_set);
+ new (this->value_ptr()) T(std::move(value));
+ m_set = true;
+ }
+
void reset()
{
if (m_set) {
More information about the Bf-blender-cvs
mailing list