Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_array_ref.hh')
-rw-r--r--source/blender/blenlib/BLI_array_ref.hh10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_array_ref.hh b/source/blender/blenlib/BLI_array_ref.hh
index dd9421d289c..c0484493bda 100644
--- a/source/blender/blenlib/BLI_array_ref.hh
+++ b/source/blender/blenlib/BLI_array_ref.hh
@@ -508,6 +508,16 @@ template<typename T> class MutableArrayRef {
BLI_assert(m_size > 0);
return m_start[m_size - 1];
}
+
+ /**
+ * Get a new array ref to the same underlying memory buffer. No conversions are done.
+ */
+ template<typename NewT> MutableArrayRef<NewT> cast() const
+ {
+ BLI_assert((m_size * sizeof(T)) % sizeof(NewT) == 0);
+ uint new_size = m_size * sizeof(T) / sizeof(NewT);
+ return MutableArrayRef<NewT>(reinterpret_cast<NewT *>(m_start), new_size);
+ }
};
/**