[Bf-blender-cvs] [a049eb9ee47] gpencil-new-data-proposal: Add initialized_reversed_move_n

Falk David noreply at git.blender.org
Tue May 17 17:38:49 CEST 2022


Commit: a049eb9ee479663dc723f5ba7b93cc2c7ac658c1
Author: Falk David
Date:   Tue May 17 17:36:23 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBa049eb9ee479663dc723f5ba7b93cc2c7ac658c1

Add initialized_reversed_move_n

This is just like initialized_move_n but moving the array from
back to front.

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

M	source/blender/blenlib/BLI_memory_utils.hh

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

diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index d7c41ae88a8..a079b33c047 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -179,6 +179,27 @@ template<typename T> void initialized_move_n(T *src, int64_t n, T *dst)
   }
 }
 
+/**
+ * Move n values from src to dst starting with the last value.
+ *
+ * Exception Safety: Basic.
+ *
+ * Before:
+ *  src: initialized
+ *  dst: initialized
+ * After:
+ *  src: initialized, moved-from
+ *  dst: initialized
+ */
+template<typename T> void initialized_reversed_move_n(T *src, int64_t n, T *dst)
+{
+  BLI_assert(n >= 0);
+
+  for (int64_t i = n - 1; i >= 0; i--) {
+    dst[i] = std::move(src[i]);
+  }
+}
+
 /**
  * Move n values from src to dst.
  *



More information about the Bf-blender-cvs mailing list