[Bf-blender-cvs] [9793bc30cec] master: BLI: Add slice method to MutableSpan

Hans Goudey noreply at git.blender.org
Mon Jan 3 23:27:22 CET 2022


Commit: 9793bc30cec959cce7a23d3b75a772f39cc3d721
Author: Hans Goudey
Date:   Mon Jan 3 16:27:13 2022 -0600
Branches: master
https://developer.blender.org/rB9793bc30cec959cce7a23d3b75a772f39cc3d721

BLI: Add slice method to MutableSpan

Span had a slice method with an IndexRange argument, but MutableSpan
did not, yet. This commit makes the two types consistent.

===================================================================

M	source/blender/blenlib/BLI_span.hh

===================================================================

diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh
index 5b7981e0302..995dc70a84d 100644
--- a/source/blender/blenlib/BLI_span.hh
+++ b/source/blender/blenlib/BLI_span.hh
@@ -599,6 +599,11 @@ template<typename T> class MutableSpan {
     return MutableSpan(data_ + start, new_size);
   }
 
+  constexpr MutableSpan slice(IndexRange range) const
+  {
+    return this->slice(range.start(), range.size());
+  }
+
   /**
    * Returns a new MutableSpan with n elements removed from the beginning. This invokes
    * undefined behavior when n is negative.



More information about the Bf-blender-cvs mailing list