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:
authorJacques Lucke <jacques@blender.org>2020-05-07 15:21:26 +0300
committerJacques Lucke <jacques@blender.org>2020-05-07 15:21:48 +0300
commit850a539c903605586d0f32bd14fc3dcf63d5a89e (patch)
treeae8bc1876409719ec6ac2329ab1bcbd6724770d1 /source/blender/blenlib/BLI_array_ref.hh
parent45adcc51b21d626238b25428f791937148cf0a20 (diff)
BLI: improve linear allocator documentation
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);
+ }
};
/**