[Bf-blender-cvs] [4df64a4393c] functions: improve move semantic usage in BLI::Optional

Jacques Lucke noreply at git.blender.org
Tue Jun 4 18:14:52 CEST 2019


Commit: 4df64a4393cd25970dc5a9704b7a78e7ada63a91
Author: Jacques Lucke
Date:   Tue Jun 4 18:14:37 2019 +0200
Branches: functions
https://developer.blender.org/rB4df64a4393cd25970dc5a9704b7a78e7ada63a91

improve move semantic usage in BLI::Optional

===================================================================

M	source/blender/blenlib/BLI_optional.hpp

===================================================================

diff --git a/source/blender/blenlib/BLI_optional.hpp b/source/blender/blenlib/BLI_optional.hpp
index a845ce270f1..904fa153e1e 100644
--- a/source/blender/blenlib/BLI_optional.hpp
+++ b/source/blender/blenlib/BLI_optional.hpp
@@ -43,7 +43,7 @@ template<typename T> class Optional {
 
   Optional(T &&value) : Optional()
   {
-    this->set(value);
+    this->set(std::forward<T>(value));
   }
 
   Optional(const Optional &other) : Optional()
@@ -118,10 +118,11 @@ template<typename T> class Optional {
   void set(T &&value)
   {
     if (m_set) {
-      std::copy_n(&value, 1, this->value_ptr());
+      std::copy_n(std::make_move_iterator(&value), 1, this->value_ptr());
     }
     else {
-      std::uninitialized_copy_n(&value, 1, this->value_ptr());
+      std::uninitialized_copy_n(std::make_move_iterator(&value), 1, this->value_ptr());
+      m_set = true;
     }
   }



More information about the Bf-blender-cvs mailing list