Blender  V3.3
Public Types | Public Member Functions | Static Public Member Functions | List of all members
blender::Array< T, InlineBufferCapacity, Allocator > Class Template Reference

#include <BLI_array.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 const_iterator = const T *
 
using size_type = int64_t
 

Public Member Functions

 Array (Allocator allocator={}) noexcept
 
 Array (NoExceptConstructor, Allocator allocator={}) noexcept
 
template<typename U , BLI_ENABLE_IF((std::is_convertible_v< U, T >)) >
 Array (Span< U > values, Allocator allocator={})
 
template<typename U , BLI_ENABLE_IF((std::is_convertible_v< U, T >)) >
 Array (const std::initializer_list< U > &values, Allocator allocator={})
 
 Array (const std::initializer_list< T > &values, Allocator allocator={})
 
 Array (int64_t size, Allocator allocator={})
 
 Array (int64_t size, const T &value, Allocator allocator={})
 
 Array (int64_t size, NoInitialization, Allocator allocator={})
 
 Array (const Array &other)
 
 Array (Array &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 
 ~Array ()
 
Arrayoperator= (const Array &other)
 
Arrayoperator= (Array &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 
Toperator[] (int64_t index)
 
const Toperator[] (int64_t index) const
 
 operator Span< T > () const
 
 operator MutableSpan< T > ()
 
template<typename U , BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >)) >
 operator Span< U > () const
 
template<typename U , BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >)) >
 operator MutableSpan< U > ()
 
Span< Tas_span () const
 
MutableSpan< Tas_mutable_span ()
 
int64_t size () const
 
bool is_empty () const
 
void fill (const T &value) const
 
const Tfirst () const
 
Tfirst ()
 
const Tlast (const int64_t n=0) const
 
Tlast (const int64_t n=0)
 
const Tdata () const
 
Tdata ()
 
const Tbegin () const
 
const Tend () const
 
Tbegin ()
 
Tend ()
 
std::reverse_iterator< T * > rbegin ()
 
std::reverse_iterator< T * > rend ()
 
std::reverse_iterator< const T * > rbegin () const
 
std::reverse_iterator< const T * > rend () const
 
IndexRange index_range () const
 
void clear_without_destruct ()
 
Allocator & allocator ()
 
const Allocator & allocator () const
 
void reinitialize (const int64_t new_size)
 

Static Public Member Functions

static int64_t inline_buffer_capacity ()
 

Detailed Description

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
class blender::Array< T, InlineBufferCapacity, Allocator >

Definition at line 48 of file BLI_array.hh.

Member Typedef Documentation

◆ const_iterator

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_iterator = const T *

Definition at line 56 of file BLI_array.hh.

◆ const_pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_pointer = const T *

Definition at line 52 of file BLI_array.hh.

◆ const_reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_reference = const T &

Definition at line 54 of file BLI_array.hh.

◆ iterator

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::iterator = T *

Definition at line 55 of file BLI_array.hh.

◆ pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::pointer = T *

Definition at line 51 of file BLI_array.hh.

◆ reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::reference = T &

Definition at line 53 of file BLI_array.hh.

◆ size_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::size_type = int64_t

Definition at line 57 of file BLI_array.hh.

◆ value_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::value_type = T

Definition at line 50 of file BLI_array.hh.

Constructor & Destructor Documentation

◆ Array() [1/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Allocator  allocator = {})
inlinenoexcept

By default an empty array is created.

Definition at line 76 of file BLI_array.hh.

◆ Array() [2/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( NoExceptConstructor  ,
Allocator  allocator = {} 
)
inlinenoexcept

Definition at line 82 of file BLI_array.hh.

◆ Array() [3/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , BLI_ENABLE_IF((std::is_convertible_v< U, T >)) >
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Span< U values,
Allocator  allocator = {} 
)
inline

Create a new array that contains copies of all values.

Definition at line 90 of file BLI_array.hh.

◆ Array() [4/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , BLI_ENABLE_IF((std::is_convertible_v< U, T >)) >
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const std::initializer_list< U > &  values,
Allocator  allocator = {} 
)
inline

Create a new array that contains copies of all values.

Definition at line 102 of file BLI_array.hh.

◆ Array() [5/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const std::initializer_list< T > &  values,
Allocator  allocator = {} 
)
inline

Definition at line 107 of file BLI_array.hh.

◆ Array() [6/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
Allocator  allocator = {} 
)
inlineexplicit

Create a new array with the given size. All values will be default constructed. For trivial types like int, default construction does nothing.

We might want another version of this in the future, that does not do default construction even for non-trivial types. This should not be the default though, because one can easily mess up when dealing with uninitialized memory.

Definition at line 120 of file BLI_array.hh.

◆ Array() [7/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
const T value,
Allocator  allocator = {} 
)
inline

Create a new array with the given size. All values will be initialized by copying the given default.

Definition at line 131 of file BLI_array.hh.

◆ Array() [8/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
NoInitialization  ,
Allocator  allocator = {} 
)
inline

Create a new array with uninitialized elements. The caller is responsible for constructing the elements. Moving, copying or destructing an Array with uninitialized elements invokes undefined behavior.

This should be used very rarely. Note, that the normal size-constructor also does not initialize the elements when T is trivially constructible. Therefore, it only makes sense to use this with non trivially constructible types.

Usage: Array<std::string> my_strings(10, NoInitialization());

Definition at line 152 of file BLI_array.hh.

◆ Array() [9/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const Array< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 160 of file BLI_array.hh.

◆ Array() [10/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Array< T, InlineBufferCapacity, Allocator > &&  other)
inlinenoexcept

Definition at line 164 of file BLI_array.hh.

References data_, and blender::uninitialized_relocate_n().

◆ ~Array()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::~Array ( )
inline

Member Function Documentation

◆ allocator() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Allocator& blender::Array< T, InlineBufferCapacity, Allocator >::allocator ( )
inline

Access the allocator used by this array.

Definition at line 365 of file BLI_array.hh.

◆ allocator() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const Allocator& blender::Array< T, InlineBufferCapacity, Allocator >::allocator ( ) const
inline

Definition at line 369 of file BLI_array.hh.

◆ as_mutable_span()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
MutableSpan<T> blender::Array< T, InlineBufferCapacity, Allocator >::as_mutable_span ( )
inline

◆ as_span()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Span<T> blender::Array< T, InlineBufferCapacity, Allocator >::as_span ( ) const
inline

◆ begin() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::begin ( )
inline

Definition at line 318 of file BLI_array.hh.

References data_.

◆ begin() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::begin ( ) const
inline

◆ clear_without_destruct()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::clear_without_destruct ( )
inline

Sets the size to zero. This should only be used when you have manually destructed all elements in the array beforehand. Use with care.

Definition at line 357 of file BLI_array.hh.

◆ data() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::data ( )
inline

Definition at line 304 of file BLI_array.hh.

References data_.

◆ data() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::data ( ) const
inline

◆ end() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::end ( )
inline

Definition at line 322 of file BLI_array.hh.

References data_.

◆ end() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::end ( ) const
inline

◆ fill()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::fill ( const T value) const
inline

◆ first() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Array< T, InlineBufferCapacity, Allocator >::first ( )
inline

Definition at line 274 of file BLI_array.hh.

References BLI_assert, and data_.

◆ first() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Array< T, InlineBufferCapacity, Allocator >::first ( ) const
inline

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

Definition at line 269 of file BLI_array.hh.

References BLI_assert, and data_.

Referenced by blender::ed::sculpt_paint::move_last_point_and_resample(), blender::nodes::node_geo_attribute_statistic_cc::node_geo_exec(), and blender::nodes::node_geo_dual_mesh_cc::sort_vertex_polys().

◆ index_range()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
IndexRange blender::Array< T, InlineBufferCapacity, Allocator >::index_range ( ) const
inline

◆ inline_buffer_capacity()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
static int64_t blender::Array< T, InlineBufferCapacity, Allocator >::inline_buffer_capacity ( )
inlinestatic

Get the value of the InlineBufferCapacity template argument. This is the number of elements that can be stored without doing an allocation.

Definition at line 378 of file BLI_array.hh.

◆ is_empty()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool blender::Array< T, InlineBufferCapacity, Allocator >::is_empty ( ) const
inline

Returns true when the number of elements in the array is zero.

Definition at line 252 of file BLI_array.hh.

Referenced by apply_objects_internal(), blendthumb_create_png_data_from_thumb(), BM_mesh_bm_from_me(), blender::GVectorArray::is_empty(), and object_origin_set_exec().

◆ last() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Array< T, InlineBufferCapacity, Allocator >::last ( const int64_t  n = 0)
inline

Definition at line 290 of file BLI_array.hh.

References BLI_assert, and data_.

◆ last() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Array< T, InlineBufferCapacity, Allocator >::last ( const int64_t  n = 0) const
inline

◆ operator MutableSpan< T >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::operator MutableSpan< T > ( )
inline

Definition at line 214 of file BLI_array.hh.

◆ operator MutableSpan< U >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >)) >
blender::Array< T, InlineBufferCapacity, Allocator >::operator MutableSpan< U > ( )
inline

Definition at line 226 of file BLI_array.hh.

References data_.

◆ operator Span< T >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::operator Span< T > ( ) const
inline

Definition at line 209 of file BLI_array.hh.

◆ operator Span< U >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >)) >
blender::Array< T, InlineBufferCapacity, Allocator >::operator Span< U > ( ) const
inline

Definition at line 220 of file BLI_array.hh.

References data_.

◆ operator=() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Array& blender::Array< T, InlineBufferCapacity, Allocator >::operator= ( Array< T, InlineBufferCapacity, Allocator > &&  other)
inlinenoexcept

Definition at line 190 of file BLI_array.hh.

References blender::move_assign_container().

◆ operator=() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Array& blender::Array< T, InlineBufferCapacity, Allocator >::operator= ( const Array< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 185 of file BLI_array.hh.

References blender::copy_assign_container().

◆ operator[]() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Array< T, InlineBufferCapacity, Allocator >::operator[] ( int64_t  index)
inline

Definition at line 195 of file BLI_array.hh.

References BLI_assert, and data_.

◆ operator[]() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Array< T, InlineBufferCapacity, Allocator >::operator[] ( int64_t  index) const
inline

Definition at line 202 of file BLI_array.hh.

References BLI_assert, and data_.

◆ rbegin() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<T *> blender::Array< T, InlineBufferCapacity, Allocator >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<const T *> blender::Array< T, InlineBufferCapacity, Allocator >::rbegin ( ) const
inline

◆ reinitialize()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::reinitialize ( const int64_t  new_size)
inline

◆ rend() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<T *> blender::Array< T, InlineBufferCapacity, Allocator >::rend ( )
inline

◆ rend() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<const T *> blender::Array< T, InlineBufferCapacity, Allocator >::rend ( ) const
inline

◆ size()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
int64_t blender::Array< T, InlineBufferCapacity, Allocator >::size ( ) const
inline

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