Blender  V3.3
Public Member Functions | Protected Attributes | List of all members
blender::GArray< Allocator > Class Template Reference

#include <BLI_generic_array.hh>

Public Member Functions

 GArray (Allocator allocator={}) noexcept
 
 GArray (NoExceptConstructor, Allocator allocator={}) noexcept
 
 GArray (const CPPType &type, int64_t size, Allocator allocator={})
 
 GArray (const CPPType &type, Allocator allocator={})
 
 GArray (const CPPType &type, void *buffer, int64_t size, Allocator allocator={})
 
 GArray (const GSpan span, Allocator allocator={})
 
 GArray (const GArray &other)
 
 GArray (GArray &&other)
 
 ~GArray ()
 
GArrayoperator= (const GArray &other)
 
GArrayoperator= (GArray &&other)
 
const CPPTypetype () const
 
bool is_empty () const
 
int64_t size () const
 
const voiddata () const
 
voiddata ()
 
const voidoperator[] (int64_t index) const
 
voidoperator[] (int64_t index)
 
 operator GSpan () const
 
 operator GMutableSpan ()
 
GSpan as_span () const
 
GMutableSpan as_mutable_span ()
 
Allocator & allocator ()
 
const Allocator & allocator () const
 
void reinitialize (const int64_t new_size)
 

Protected Attributes

const CPPTypetype_ = nullptr
 
voiddata_ = nullptr
 
int64_t size_ = 0
 
BLI_NO_UNIQUE_ADDRESS Allocator allocator_
 

Detailed Description

template<typename Allocator = GuardedAllocator>
class blender::GArray< Allocator >

Definition at line 28 of file BLI_generic_array.hh.

Constructor & Destructor Documentation

◆ GArray() [1/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( Allocator  allocator = {})
inlinenoexcept

The default constructor creates an empty array, the only situation in which the type is allowed to be null. This default constructor exists so GArray can be used in containers, but the type should be supplied before doing anything else to the array.

Definition at line 44 of file BLI_generic_array.hh.

◆ GArray() [2/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( NoExceptConstructor  ,
Allocator  allocator = {} 
)
inlinenoexcept

Definition at line 48 of file BLI_generic_array.hh.

◆ GArray() [3/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( const CPPType type,
int64_t  size,
Allocator  allocator = {} 
)
inline

Create and allocate a new array, with elements default constructed (which does not do anything for trivial types).

Definition at line 56 of file BLI_generic_array.hh.

◆ GArray() [4/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( const CPPType type,
Allocator  allocator = {} 
)
inline

Create an empty array with just a type.

Definition at line 67 of file BLI_generic_array.hh.

◆ GArray() [5/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( const CPPType type,
void buffer,
int64_t  size,
Allocator  allocator = {} 
)
inline

Take ownership of a buffer with a provided size. The buffer should be allocated with the same allocator provided to the constructor.

Definition at line 76 of file BLI_generic_array.hh.

◆ GArray() [6/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( const GSpan  span,
Allocator  allocator = {} 
)
inline

Create an array by copying values from a generic span.

Definition at line 90 of file BLI_generic_array.hh.

◆ GArray() [7/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( const GArray< Allocator > &  other)
inline

Create an array by copying values from another generic array.

Definition at line 102 of file BLI_generic_array.hh.

◆ GArray() [8/8]

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::GArray ( GArray< Allocator > &&  other)
inline

Create an array by taking ownership of another array's data, clearing the data in the other.

Definition at line 109 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::data_.

◆ ~GArray()

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::~GArray ( )
inline

Member Function Documentation

◆ allocator() [1/2]

template<typename Allocator = GuardedAllocator>
Allocator& blender::GArray< Allocator >::allocator ( )
inline

Access the allocator used by this array.

Definition at line 201 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::allocator_.

◆ allocator() [2/2]

template<typename Allocator = GuardedAllocator>
const Allocator& blender::GArray< Allocator >::allocator ( ) const
inline

Definition at line 205 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::allocator_.

◆ as_mutable_span()

template<typename Allocator = GuardedAllocator>
GMutableSpan blender::GArray< Allocator >::as_mutable_span ( )
inline

◆ as_span()

template<typename Allocator = GuardedAllocator>
GSpan blender::GArray< Allocator >::as_span ( ) const
inline

◆ data() [1/2]

template<typename Allocator = GuardedAllocator>
void* blender::GArray< Allocator >::data ( )
inline

Definition at line 159 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::data_.

◆ data() [2/2]

template<typename Allocator = GuardedAllocator>
const void* blender::GArray< Allocator >::data ( ) const
inline

Get a pointer to the beginning of the array.

Definition at line 155 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::data_.

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

◆ is_empty()

template<typename Allocator = GuardedAllocator>
bool blender::GArray< Allocator >::is_empty ( ) const
inline

Definition at line 139 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::size_.

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

◆ operator GMutableSpan()

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::operator GMutableSpan ( )
inline

◆ operator GSpan()

template<typename Allocator = GuardedAllocator>
blender::GArray< Allocator >::operator GSpan ( ) const
inline

◆ operator=() [1/2]

template<typename Allocator = GuardedAllocator>
GArray& blender::GArray< Allocator >::operator= ( const GArray< Allocator > &  other)
inline

Definition at line 123 of file BLI_generic_array.hh.

References blender::copy_assign_container().

◆ operator=() [2/2]

template<typename Allocator = GuardedAllocator>
GArray& blender::GArray< Allocator >::operator= ( GArray< Allocator > &&  other)
inline

Definition at line 128 of file BLI_generic_array.hh.

References blender::move_assign_container().

◆ operator[]() [1/2]

template<typename Allocator = GuardedAllocator>
void* blender::GArray< Allocator >::operator[] ( int64_t  index)
inline

◆ operator[]() [2/2]

template<typename Allocator = GuardedAllocator>
const void* blender::GArray< Allocator >::operator[] ( int64_t  index) const
inline

◆ reinitialize()

template<typename Allocator = GuardedAllocator>
void blender::GArray< Allocator >::reinitialize ( const int64_t  new_size)
inline

Destruct values and create a new array of the given size. The values in the new array are default constructed.

Definition at line 214 of file BLI_generic_array.hh.

References BLI_assert, blender::GArray< Allocator >::data_, blender::CPPType::default_construct_n(), blender::CPPType::destruct_n(), blender::GArray< Allocator >::size_, and blender::GArray< Allocator >::type_.

◆ size()

template<typename Allocator = GuardedAllocator>
int64_t blender::GArray< Allocator >::size ( ) const
inline

Return the number of elements in the array (not the size in bytes).

Definition at line 147 of file BLI_generic_array.hh.

References blender::GArray< Allocator >::size_.

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

◆ type()

template<typename Allocator = GuardedAllocator>
const CPPType& blender::GArray< Allocator >::type ( ) const
inline

Definition at line 133 of file BLI_generic_array.hh.

References BLI_assert, and blender::GArray< Allocator >::type_.

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

Member Data Documentation

◆ allocator_

template<typename Allocator = GuardedAllocator>
BLI_NO_UNIQUE_ADDRESS Allocator blender::GArray< Allocator >::allocator_
protected

Definition at line 36 of file BLI_generic_array.hh.

Referenced by blender::GArray< Allocator >::allocator().

◆ data_

template<typename Allocator = GuardedAllocator>
void* blender::GArray< Allocator >::data_ = nullptr
protected

◆ size_

template<typename Allocator = GuardedAllocator>
int64_t blender::GArray< Allocator >::size_ = 0
protected

◆ type_

template<typename Allocator = GuardedAllocator>
const CPPType* blender::GArray< Allocator >::type_ = nullptr
protected

The type of the data in the array, will be null after the array is default constructed, but a value should be assigned before any other interaction with the array.

Definition at line 32 of file BLI_generic_array.hh.

Referenced by blender::GArray< Allocator >::operator GMutableSpan(), blender::GArray< Allocator >::operator GSpan(), blender::GArray< Allocator >::operator[](), blender::GArray< Allocator >::reinitialize(), blender::GArray< Allocator >::type(), and blender::GArray< Allocator >::~GArray().


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