diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-07 10:34:07 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-07 10:34:07 +0300 |
commit | 120a17a45a6d6c7f5520c8bfa32a0938f29a46be (patch) | |
tree | 22c2c63a975af9fd66cd1aa10205541075d27259 /source/blender/blenlib/BLI_cpp_type.hh | |
parent | e2f4c4db8d6cbe4694c24d599e16ee3889871bdd (diff) |
BLI: add CPPType utility to copy elements to a shorter array
Diffstat (limited to 'source/blender/blenlib/BLI_cpp_type.hh')
-rw-r--r-- | source/blender/blenlib/BLI_cpp_type.hh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh index 9453eb89a2e..dd14cca7a0b 100644 --- a/source/blender/blenlib/BLI_cpp_type.hh +++ b/source/blender/blenlib/BLI_cpp_type.hh @@ -118,9 +118,11 @@ class CPPType : NonCopyable, NonMovable { void (*copy_assign_)(const void *src, void *dst) = nullptr; void (*copy_assign_indices_)(const void *src, void *dst, IndexMask mask) = nullptr; + void (*copy_assign_compressed_)(const void *src, void *dst, IndexMask mask) = nullptr; void (*copy_construct_)(const void *src, void *dst) = nullptr; void (*copy_construct_indices_)(const void *src, void *dst, IndexMask mask) = nullptr; + void (*copy_construct_compressed_)(const void *src, void *dst, IndexMask mask) = nullptr; void (*move_assign_)(void *src, void *dst) = nullptr; void (*move_assign_indices_)(void *src, void *dst, IndexMask mask) = nullptr; @@ -409,6 +411,18 @@ class CPPType : NonCopyable, NonMovable { } /** + * Similar to #copy_assign_indices, but does not leave gaps in the #dst array. + */ + void copy_assign_compressed(const void *src, void *dst, IndexMask mask) const + { + BLI_assert(mask.size() == 0 || src != dst); + BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); + BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); + + copy_assign_compressed_(src, dst, mask); + } + + /** * Copy an instance of this type from src to dst. * * The memory pointed to by dst should be uninitialized. @@ -440,6 +454,18 @@ class CPPType : NonCopyable, NonMovable { } /** + * Similar to #copy_construct_indices, but does not leave gaps in the #dst array. + */ + void copy_construct_compressed(const void *src, void *dst, IndexMask mask) const + { + BLI_assert(mask.size() == 0 || src != dst); + BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); + BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); + + copy_construct_compressed_(src, dst, mask); + } + + /** * Move an instance of this type from src to dst. * * The memory pointed to by dst should be initialized. |