diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-23 18:54:31 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-23 18:54:31 +0300 |
commit | cf123da640b0a58284a24675646f66d70a94ae30 (patch) | |
tree | 9f9063b6545d48642551bd7410f29b2d0b869a01 /source/blender/blenlib/BLI_span.hh | |
parent | 4619562e2f4c7f7f441212f0438c439a98aa4a71 (diff) |
BLI: Add MutableSpan.copy_from method
Diffstat (limited to 'source/blender/blenlib/BLI_span.hh')
-rw-r--r-- | source/blender/blenlib/BLI_span.hh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 2d875fe73be..39259e9ee18 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -609,6 +609,17 @@ template<typename T> class MutableSpan { } /** + * Copy all values from another span into this span. This invokes undefined behavior when the + * destination contains uninitialized data and T is not trivially copy constructible. + * The size of both spans is expected to be the same. + */ + void copy_from(Span<T> values) + { + BLI_assert(size_ == values.size()); + initialized_copy_n(values.data(), size_, start_); + } + + /** * Returns a new span to the same underlying memory buffer. No conversions are done. */ template<typename NewT> MutableSpan<NewT> cast() const |