[Bf-blender-cvs] [3c81c77cf14] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal
Hans Goudey
noreply at git.blender.org
Mon Dec 12 20:35:46 CET 2022
Commit: 3c81c77cf142b59173b7f2b1426274aece9a8d12
Author: Hans Goudey
Date: Mon Dec 12 12:15:44 2022 -0600
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB3c81c77cf142b59173b7f2b1426274aece9a8d12
Merge branch 'master' into gpencil-new-data-proposal
===================================================================
===================================================================
diff --cc source/blender/blenlib/BLI_memory_utils.hh
index c97a4424d95,6f119a49f01..b82108f66a1
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@@ -147,119 -58,21 +58,42 @@@ template<typename T> void uninitialized
template<typename From, typename To>
void uninitialized_convert_n(const From *src, int64_t n, To *dst)
{
- BLI_assert(n >= 0);
-
- int64_t current = 0;
- try {
- for (; current < n; current++) {
- new (static_cast<void *>(dst + current)) To(static_cast<To>(src[current]));
- }
- }
- catch (...) {
- destruct_n(dst, current);
- throw;
- }
+ std::uninitialized_copy_n(src, n, dst);
}
- /**
- * Move n values from src to dst.
- *
- * Exception Safety: Basic.
- *
- * Before:
- * src: initialized
- * dst: initialized
- * After:
- * src: initialized, moved-from
- * dst: initialized
- */
template<typename T> void initialized_move_n(T *src, int64_t n, T *dst)
{
- BLI_assert(n >= 0);
-
- for (int64_t i = 0; i < n; i++) {
- dst[i] = std::move(src[i]);
- }
+ std::copy_n(std::make_move_iterator(src), n, dst);
}
- /**
- * Move n values from src to dst.
- *
- * Exception Safety: Basic.
- *
- * Before:
- * src: initialized
- * dst: uninitialized
- * After:
- * src: initialized, moved-from
- * dst: initialized
- */
template<typename T> void uninitialized_move_n(T *src, int64_t n, T *dst)
{
- BLI_assert(n >= 0);
-
- int64_t current = 0;
- try {
- for (; current < n; current++) {
- new (static_cast<void *>(dst + current)) T(std::move(src[current]));
- }
- }
- catch (...) {
- destruct_n(dst, current);
- throw;
- }
+ std::uninitialized_copy_n(std::make_move_iterator(src), n, 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]);
+ }
+}
+
- /**
- * Relocate n values from src to dst. Relocation is a move followed by destruction of the src
- * value.
- *
- * Exception Safety: Basic.
- *
- * Before:
- * src: initialized
- * dst: initialized
- * After:
- * src: uninitialized
- * dst: initialized
- */
template<typename T> void initialized_relocate_n(T *src, int64_t n, T *dst)
{
- BLI_assert(n >= 0);
-
initialized_move_n(src, n, dst);
destruct_n(src, n);
}
More information about the Bf-blender-cvs
mailing list