Blender  V2.93
Public Types | Public Member Functions | List of all members
blender::MutableSpan< T > Class Template Reference

#include <BLI_span.hh>

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 , typename std::enable_if_t< is_span_convertible_pointer_v< U, T >> * = nullptr>
constexpr MutableSpan (MutableSpan< U > span)
 
constexpr operator Span< T > () const
 
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
constexpr operator Span< U > () const
 
constexpr int64_t size () const
 
constexpr bool is_empty () const
 
constexpr void fill (const T &value)
 
constexpr void fill_indices (Span< int64_t > indices, const T &value)
 
constexpr Tdata () const
 
constexpr Tbegin () const
 
constexpr Tend () const
 
constexpr std::reverse_iterator< T * > rbegin () const
 
constexpr std::reverse_iterator< T * > rend () const
 
constexpr Toperator[] (const int64_t index) const
 
constexpr MutableSpan slice (const int64_t start, const int64_t size) 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 Span< Tas_span () const
 
constexpr IndexRange index_range () const
 
constexpr Tlast () const
 
constexpr int64_t count (const T &value) const
 
constexpr void copy_from (Span< T > values)
 
template<typename NewT >
constexpr MutableSpan< NewT > cast () const
 

Detailed Description

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

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

Definition at line 470 of file BLI_span.hh.

Member Typedef Documentation

◆ const_pointer

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

Definition at line 474 of file BLI_span.hh.

◆ const_reference

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

Definition at line 476 of file BLI_span.hh.

◆ iterator

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

Definition at line 477 of file BLI_span.hh.

◆ pointer

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

Definition at line 473 of file BLI_span.hh.

◆ reference

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

Definition at line 475 of file BLI_span.hh.

◆ size_type

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

Definition at line 478 of file BLI_span.hh.

◆ value_type

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

Definition at line 472 of file BLI_span.hh.

Constructor & Destructor Documentation

◆ MutableSpan() [1/5]

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

◆ MutableSpan() [2/5]

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

Definition at line 487 of file BLI_span.hh.

References data_.

◆ MutableSpan() [3/5]

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

Definition at line 491 of file BLI_span.hh.

◆ MutableSpan() [4/5]

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

Definition at line 496 of file BLI_span.hh.

◆ MutableSpan() [5/5]

template<typename T >
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< U, T >> * = nullptr>
constexpr blender::MutableSpan< T >::MutableSpan ( MutableSpan< U span)
inlineconstexpr

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

Definition at line 505 of file BLI_span.hh.

References data_.

Member Function Documentation

◆ as_span()

template<typename T >
constexpr Span<T> 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 650 of file BLI_span.hh.

References data_.

◆ begin()

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

Definition at line 566 of file BLI_span.hh.

References data_.

Referenced by blender::MutableSpan< T >::rend().

◆ cast()

template<typename T >
template<typename NewT >
constexpr MutableSpan<NewT> 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 704 of file BLI_span.hh.

References BLI_assert, data_, and T.

Referenced by blender::LinearAllocator< Allocator >::construct_elements_and_pointer_array().

◆ copy_from()

template<typename T >
constexpr void blender::MutableSpan< T >::copy_from ( Span< T values)
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 694 of file BLI_span.hh.

References BLI_assert, blender::Span< T >::data(), data_, blender::initialized_copy_n(), and blender::Span< T >::size().

Referenced by blender::gpu::sort_input_list(), and blender::tests::TEST().

◆ count()

template<typename T >
constexpr int64_t 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 678 of file BLI_span.hh.

References element, and T.

◆ data()

template<typename T >
constexpr T* 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 561 of file BLI_span.hh.

References data_.

Referenced by blender::LinearAllocator< Allocator >::construct_array_copy(), and blender::tests::TEST().

◆ drop_back()

template<typename T >
constexpr MutableSpan 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 617 of file BLI_span.hh.

References BLI_assert, data_, and blender::MutableSpan< T >::MutableSpan().

◆ drop_front()

template<typename T >
constexpr MutableSpan 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 606 of file BLI_span.hh.

References BLI_assert, data_, and blender::MutableSpan< T >::MutableSpan().

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

◆ end()

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

Definition at line 570 of file BLI_span.hh.

References data_.

Referenced by blender::MutableSpan< T >::rbegin().

◆ fill()

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

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

Definition at line 540 of file BLI_span.hh.

References data_, and blender::initialized_fill_n().

Referenced by blender::bke::adapt_mesh_domain_face_to_corner_impl(), blender::string_search::match_word_initials(), and blender::tests::TEST().

◆ fill_indices()

template<typename T >
constexpr void blender::MutableSpan< T >::fill_indices ( Span< int64_t indices,
const T value 
)
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 549 of file BLI_span.hh.

References BLI_assert, data_, and indices.

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

◆ index_range()

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

◆ is_empty()

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

Returns true if the size is zero.

Definition at line 532 of file BLI_span.hh.

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

◆ last()

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

Returns a reference to the last element. This invokes undefined behavior when the array is empty.

Definition at line 668 of file BLI_span.hh.

References BLI_assert, and data_.

◆ operator Span< T >()

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

Definition at line 510 of file BLI_span.hh.

◆ operator Span< U >()

template<typename T >
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
constexpr blender::MutableSpan< T >::operator Span< U > ( ) const
inlineconstexpr

Definition at line 516 of file BLI_span.hh.

References data_.

◆ operator[]()

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

Definition at line 584 of file BLI_span.hh.

References BLI_assert, data_, and blender::MutableSpan< T >::size().

◆ rbegin()

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

Definition at line 575 of file BLI_span.hh.

References blender::MutableSpan< T >::end().

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

◆ rend()

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

Definition at line 579 of file BLI_span.hh.

References blender::MutableSpan< T >::begin().

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

◆ size()

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

◆ slice()

template<typename T >
constexpr MutableSpan 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 594 of file BLI_span.hh.

References BLI_assert, data_, min, blender::MutableSpan< T >::MutableSpan(), and blender::MutableSpan< T >::size().

Referenced by blender::bke::adapt_mesh_domain_face_to_corner_impl(), blender::nodes::compute_special_attributes(), and blender::tests::TEST().

◆ take_back()

template<typename T >
constexpr MutableSpan 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 639 of file BLI_span.hh.

References BLI_assert, data_, and blender::MutableSpan< T >::MutableSpan().

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

◆ take_front()

template<typename T >
constexpr MutableSpan 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 628 of file BLI_span.hh.

References BLI_assert, data_, and blender::MutableSpan< T >::MutableSpan().

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


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