Blender V5.3
blender::blender::MutableSpan< T > Class Template Reference

#include <bmesh_polygon.hh>

Inherited by blender::MutableVArraySpan< T >.

Public Types

using value_type = T
using pointer = T *
using const_pointer = const T *
using reference = T &
using const_reference = const T &
using iterator = T *
using size_type = int64_t

Public Member Functions

constexpr MutableSpan ()=default
constexpr MutableSpan (T *start, const int64_t size)
constexpr MutableSpan (std::vector< T > &vector)
template<std::size_t N>
constexpr MutableSpan (std::array< T, N > &array)
template<typename U>
requires (is_span_convertible_pointer_v<U, T>)
constexpr MutableSpan (MutableSpan< U > span)
constexpr operator Span< T > () const
template<typename U>
requires (is_span_convertible_pointer_v<T, U>)
constexpr operator Span< U > () const
constexpr int64_t size () const
constexpr int64_t size_in_bytes () const
constexpr bool is_empty () const
constexpr void fill (const T &value) const
template<typename IndexT>
constexpr void fill_indices (Span< IndexT > indices, const T &value) const
constexpr T * data () const
constexpr T * begin () const
constexpr T * end () const
constexpr std::reverse_iterator< T * > rbegin () const
constexpr std::reverse_iterator< T * > rend () const
constexpr T & operator[] (const int64_t index) const
constexpr MutableSpan slice (const int64_t start, const int64_t size) const
constexpr MutableSpan slice (IndexRange range) const
constexpr MutableSpan slice_safe (const int64_t start, const int64_t size) const
constexpr MutableSpan slice_safe (IndexRange range) const
constexpr MutableSpan drop_front (const int64_t n) const
constexpr MutableSpan drop_back (const int64_t n) const
constexpr MutableSpan take_front (const int64_t n) const
constexpr MutableSpan take_back (const int64_t n) const
constexpr void reverse () const
constexpr Span< T > as_span () const
constexpr IndexRange index_range () const
constexpr T & first () const
constexpr T & last (const int64_t n=0) const
constexpr int64_t count (const T &value) const
constexpr bool contains (const T &value) const
constexpr bool contains_ptr (const T *ptr) const
constexpr void copy_from (Span< T > values) const
template<typename NewT>
constexpr MutableSpan< NewT > cast () const

Protected Attributes

T * data_ = nullptr
int64_t size_ = 0

Detailed Description

template<typename T>
class blender::blender::MutableSpan< T >

Mostly the same as Span, except that one can change the array elements through a MutableSpan.

Definition at line 447 of file bmesh_polygon.hh.

Member Typedef Documentation

◆ const_pointer

template<typename T>
using blender::blender::MutableSpan< T >::const_pointer = const T *

Definition at line 451 of file bmesh_polygon.hh.

◆ const_reference

template<typename T>
using blender::blender::MutableSpan< T >::const_reference = const T &

Definition at line 453 of file bmesh_polygon.hh.

◆ iterator

template<typename T>
using blender::blender::MutableSpan< T >::iterator = T *

Definition at line 454 of file bmesh_polygon.hh.

◆ pointer

template<typename T>
using blender::blender::MutableSpan< T >::pointer = T *

Definition at line 450 of file bmesh_polygon.hh.

◆ reference

template<typename T>
using blender::blender::MutableSpan< T >::reference = T &

Definition at line 452 of file bmesh_polygon.hh.

◆ size_type

template<typename T>
using blender::blender::MutableSpan< T >::size_type = int64_t

Definition at line 455 of file bmesh_polygon.hh.

◆ value_type

template<typename T>
using blender::blender::MutableSpan< T >::value_type = T

Definition at line 449 of file bmesh_polygon.hh.

Constructor & Destructor Documentation

◆ MutableSpan() [1/5]

template<typename T>
blender::blender::MutableSpan< T >::MutableSpan ( )
constexprdefault

◆ MutableSpan() [2/5]

template<typename T>
blender::blender::MutableSpan< T >::MutableSpan ( T * start,
const int64_t size )
inlineconstexpr

Definition at line 464 of file bmesh_polygon.hh.

◆ MutableSpan() [3/5]

template<typename T>
blender::blender::MutableSpan< T >::MutableSpan ( std::vector< T > & vector)
inlineconstexpr

Definition at line 466 of file bmesh_polygon.hh.

◆ MutableSpan() [4/5]

template<typename T>
template<std::size_t N>
blender::blender::MutableSpan< T >::MutableSpan ( std::array< T, N > & array)
inlineconstexpr

Definition at line 469 of file bmesh_polygon.hh.

◆ MutableSpan() [5/5]

template<typename T>
template<typename U>
requires (is_span_convertible_pointer_v<U, T>)
blender::blender::MutableSpan< T >::MutableSpan ( MutableSpan< U > span)
inlineconstexpr

Support implicit conversions like the one below: MutableSpan<T *> -> MutableSpan<const T *>

Definition at line 478 of file bmesh_polygon.hh.

Member Function Documentation

◆ as_span()

template<typename T>
Span< T > blender::blender::MutableSpan< T >::as_span ( ) const
inlineconstexpr

Returns an (immutable) Span that references the same array. This is usually not needed, due to implicit conversions. However, sometimes automatic type deduction needs some help.

Definition at line 667 of file bmesh_polygon.hh.

◆ begin()

template<typename T>
T * blender::blender::MutableSpan< T >::begin ( ) const
inlineconstexpr

Definition at line 550 of file bmesh_polygon.hh.

◆ cast()

template<typename T>
template<typename NewT>
MutableSpan< NewT > blender::blender::MutableSpan< T >::cast ( ) const
inlineconstexpr

Returns a new span to the same underlying memory buffer. No conversions are done. The caller is responsible for making sure that the type cast is valid.

Definition at line 755 of file bmesh_polygon.hh.

◆ contains()

template<typename T>
bool blender::blender::MutableSpan< T >::contains ( const T & value) const
inlineconstexpr

Does a linear search to see of the value is in the array. Returns true if it is, otherwise false.

Definition at line 721 of file bmesh_polygon.hh.

◆ contains_ptr()

template<typename T>
bool blender::blender::MutableSpan< T >::contains_ptr ( const T * ptr) const
inlineconstexpr

Does a constant time check to see if the pointer points to a value in the referenced array. Return true if it is, otherwise false.

Definition at line 735 of file bmesh_polygon.hh.

◆ copy_from()

template<typename T>
void blender::blender::MutableSpan< T >::copy_from ( Span< T > values) const
inlineconstexpr

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.

Definition at line 745 of file bmesh_polygon.hh.

Referenced by blender::arrayModifier_doArray(), blender::BKE_keyblock_convert_to_mesh(), blender::BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(), blender::build_sequential(), blender::create_envelope_strokes(), blender::MOD_solidify_extrude_modifyMesh(), blender::selectbuffer_ret_hits_5(), blender::selectbuffer_ret_hits_5(), and blender::selectbuffer_ret_hits_9().

◆ count()

template<typename T>
int64_t blender::blender::MutableSpan< T >::count ( const T & value) const
inlineconstexpr

Does a linear search to count how often the value is in the array. Returns the number of occurrences.

Definition at line 706 of file bmesh_polygon.hh.

◆ data()

template<typename T>
T * blender::blender::MutableSpan< T >::data ( ) const
inlineconstexpr

Returns a pointer to the beginning of the referenced array. This may be nullptr, when the size is zero.

Definition at line 545 of file bmesh_polygon.hh.

◆ drop_back()

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::drop_back ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan with n elements removed from the end. This invokes undefined behavior when n is negative.

Definition at line 624 of file bmesh_polygon.hh.

◆ drop_front()

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::drop_front ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan with n elements removed from the beginning. This invokes undefined behavior when n is negative.

Definition at line 613 of file bmesh_polygon.hh.

Referenced by blender::measure_chain().

◆ end()

template<typename T>
T * blender::blender::MutableSpan< T >::end ( ) const
inlineconstexpr

Definition at line 554 of file bmesh_polygon.hh.

◆ fill()

template<typename T>
void blender::blender::MutableSpan< T >::fill ( const T & value) const
inlineconstexpr

Replace all elements in the referenced array with the given value.

Definition at line 523 of file bmesh_polygon.hh.

◆ fill_indices()

template<typename T>
template<typename IndexT>
void blender::blender::MutableSpan< T >::fill_indices ( Span< IndexT > indices,
const T & value ) const
inlineconstexpr

Replace a subset of all elements with the given value. This invokes undefined behavior when one of the indices is out of bounds.

Definition at line 532 of file bmesh_polygon.hh.

◆ first()

template<typename T>
T & blender::blender::MutableSpan< T >::first ( ) const
inlineconstexpr

Return a reference to the first element in the array. This invokes undefined behavior when the array is empty.

Definition at line 685 of file bmesh_polygon.hh.

Referenced by blender::BPy_GeometrySet_static_from_evaluated_object().

◆ index_range()

template<typename T>
IndexRange blender::blender::MutableSpan< T >::index_range ( ) const
inlineconstexpr

Utility to make it more convenient to iterate over all indices that can be used with this array.

Definition at line 676 of file bmesh_polygon.hh.

Referenced by blender::BKE_mesh_material_index_remove().

◆ is_empty()

template<typename T>
bool blender::blender::MutableSpan< T >::is_empty ( ) const
inlineconstexpr

Returns true if the size is zero.

Definition at line 515 of file bmesh_polygon.hh.

Referenced by blender::tests::TEST_F().

◆ last()

template<typename T>
T & blender::blender::MutableSpan< T >::last ( const int64_t n = 0) const
inlineconstexpr

Returns a reference to the nth last element. This invokes undefined behavior when the span is too short.

Definition at line 695 of file bmesh_polygon.hh.

Referenced by blender::create_envelope_strokes().

◆ operator Span< T >()

template<typename T>
blender::blender::MutableSpan< T >::operator Span< T > ( ) const
inlineconstexpr

Definition at line 484 of file bmesh_polygon.hh.

◆ operator Span< U >()

template<typename T>
template<typename U>
requires (is_span_convertible_pointer_v<T, U>)
blender::blender::MutableSpan< T >::operator Span< U > ( ) const
inlineconstexpr

Definition at line 490 of file bmesh_polygon.hh.

◆ operator[]()

template<typename T>
T & blender::blender::MutableSpan< T >::operator[] ( const int64_t index) const
inlineconstexpr

Definition at line 568 of file bmesh_polygon.hh.

◆ rbegin()

template<typename T>
std::reverse_iterator< T * > blender::blender::MutableSpan< T >::rbegin ( ) const
inlineconstexpr

Definition at line 559 of file bmesh_polygon.hh.

◆ rend()

template<typename T>
std::reverse_iterator< T * > blender::blender::MutableSpan< T >::rend ( ) const
inlineconstexpr

Definition at line 563 of file bmesh_polygon.hh.

◆ reverse()

template<typename T>
void blender::blender::MutableSpan< T >::reverse ( ) const
inlineconstexpr

Reverse the data in the MutableSpan.

Definition at line 656 of file bmesh_polygon.hh.

Referenced by blender::faces_check_flip().

◆ size()

template<typename T>
int64_t blender::blender::MutableSpan< T >::size ( ) const
inlineconstexpr

Returns the number of elements in the array.

Definition at line 499 of file bmesh_polygon.hh.

◆ size_in_bytes()

template<typename T>
int64_t blender::blender::MutableSpan< T >::size_in_bytes ( ) const
inlineconstexpr

Returns the number of bytes referenced by this Span.

Definition at line 507 of file bmesh_polygon.hh.

◆ slice() [1/2]

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::slice ( const int64_t start,
const int64_t size ) const
inlineconstexpr

Returns a contiguous part of the array. This invokes undefined behavior when the start or size is negative.

Definition at line 579 of file bmesh_polygon.hh.

Referenced by blender::create_envelope_strokes().

◆ slice() [2/2]

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::slice ( IndexRange range) const
inlineconstexpr

Definition at line 587 of file bmesh_polygon.hh.

◆ slice_safe() [1/2]

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::slice_safe ( const int64_t start,
const int64_t size ) const
inlineconstexpr

Returns a contiguous part of the array. This invokes undefined behavior when the start or size is negative. Clamps the size of the new span so it fits in the current one.

Definition at line 596 of file bmesh_polygon.hh.

◆ slice_safe() [2/2]

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::slice_safe ( IndexRange range) const
inlineconstexpr

Definition at line 604 of file bmesh_polygon.hh.

◆ take_back()

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::take_back ( const int64_t n) const
inlineconstexpr

Return a new MutableSpan that only contains the last n elements. This invokes undefined behavior when n is negative.

Definition at line 646 of file bmesh_polygon.hh.

◆ take_front()

template<typename T>
MutableSpan blender::blender::MutableSpan< T >::take_front ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan that only contains the first n elements. This invokes undefined behavior when n is negative.

Definition at line 635 of file bmesh_polygon.hh.

Member Data Documentation

◆ data_

template<typename T>
T* blender::blender::MutableSpan< T >::data_ = nullptr
protected

Definition at line 458 of file bmesh_polygon.hh.

◆ size_


The documentation for this class was generated from the following file: