Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::sarr_soa< T, N > Class Template Reference

Fixed-size stack array with SoA storage. Interface compatiblity with std::array where it matters. More...

#include <sarray_soa_impl.h>

Public Types

using value_type = T
 Element type stored by the container.
 
using reference = T &
 Mutable element reference type.
 
using const_reference = const T &
 Read-only element reference type.
 
using pointer = T *
 Mutable element pointer type.
 
using const_pointer = T *
 Read-only element pointer type.
 
using view_policy = mem::data_view_policy_soa< T::gaia_Data_Layout, T >
 Data-layout access policy used by the container.
 
using difference_type = sarr_soa_detail::difference_type
 Type used for iterator differences.
 
using size_type = sarr_soa_detail::size_type
 Unsigned type used for sizes and indices.
 
using iterator = sarr_soa_iterator< T >
 Mutable random-access iterator type.
 
using const_iterator = const_sarr_soa_iterator< T >
 Read-only random-access iterator type.
 
using iterator_category = core::random_access_iterator_tag
 Iterator category exposed by the container.
 

Public Member Functions

 sarr_soa (core::zero_t) noexcept
 Zero-initialization constructor. Because sarr_soa is not aggretate type, doing: sarr_soa<int,10> tmp{} does not zero-initialize its internals. We need to be explicit about our intent and use a special constructor.
 
template<typename InputIt >
 sarr_soa (InputIt first, InputIt last) noexcept
 Constructs a container from an iterator range.
 
 sarr_soa (std::initializer_list< T > il)
 Constructs a container from an initializer list.
 
 sarr_soa (const sarr_soa &other)
 Copy-constructs a container.
 
 sarr_soa (sarr_soa &&other) noexcept
 Move-constructs a container.
 
sarr_soaoperator= (std::initializer_list< T > il)
 Replaces the elements from an initializer list.
 
sarr_soaoperator= (const sarr_soa &other)
 Copy-assigns the container.
 
sarr_soaoperator= (sarr_soa &&other) noexcept
 Move-assigns the container.
 
GAIA_NODISCARD pointer data () noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD const_pointer data () const noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD decltype(autooperator[] (size_type pos) noexcept
 Accesses an element without bounds checking in optimized builds.
 
GAIA_NODISCARD decltype(autooperator[] (size_type pos) const noexcept
 Accesses an element without bounds checking in optimized builds.
 
GAIA_NODISCARD constexpr size_type size () const noexcept
 Returns the number of elements.
 
GAIA_NODISCARD constexpr bool empty () const noexcept
 Checks whether the container has no elements.
 
GAIA_NODISCARD constexpr size_type capacity () const noexcept
 Returns the number of elements that fit without reallocation.
 
GAIA_NODISCARD constexpr size_type max_size () const noexcept
 Returns the maximum number of elements supported by this container.
 
GAIA_NODISCARD decltype(autofront () noexcept
 Accesses the first element.
 
GAIA_NODISCARD decltype(autofront () const noexcept
 Accesses the first element.
 
GAIA_NODISCARD decltype(autoback () noexcept
 Accesses the last element.
 
GAIA_NODISCARD decltype(autoback () const noexcept
 Accesses the last element.
 
GAIA_NODISCARD auto begin () noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD auto begin () const noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD auto cbegin () const noexcept
 Returns a read-only iterator to the first element.
 
GAIA_NODISCARD auto rbegin () noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto rbegin () const noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto crbegin () const noexcept
 Returns a read-only reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto end () noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD auto end () const noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD auto cend () const noexcept
 Returns a read-only iterator one past the last element.
 
GAIA_NODISCARD auto rend () noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD auto rend () const noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD auto crend () const noexcept
 Returns the read-only reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD bool operator== (const sarr_soa &other) const
 Compares two containers element by element.
 
GAIA_NODISCARD bool operator!= (const sarr_soa &other) const
 Checks whether two containers differ.
 
template<size_t Item>
auto view_mut () noexcept
 Returns a mutable view of one structure-of-arrays member.
 
template<size_t Item>
auto view () const noexcept
 Returns a read-only view of one structure-of-arrays member.
 

Public Attributes

mem::raw_data_holder< T, allocated_bytesm_data
 Inline storage backing the container elements.
 

Static Public Attributes

static constexpr size_type extent = N
 Fixed capacity of the container.
 
static constexpr uint32_t allocated_bytes = view_policy::get_min_byte_size(0, N)
 Number of bytes reserved by the inline storage.
 

Detailed Description

template<typename T, sarr_soa_detail::size_type N>
class gaia::cnt::sarr_soa< T, N >

Fixed-size stack array with SoA storage. Interface compatiblity with std::array where it matters.

Template Parameters
TElement type stored directly in the array.
NNumber of elements and fixed capacity.

Constructor & Destructor Documentation

◆ sarr_soa() [1/4]

template<typename T , sarr_soa_detail::size_type N>
template<typename InputIt >
gaia::cnt::sarr_soa< T, N >::sarr_soa ( InputIt  first,
InputIt  last 
)
inlinenoexcept

Constructs a container from an iterator range.

Template Parameters
InputItInput iterator type.
Parameters
firstIterator to the first source element.
lastIterator one past the last source element.

◆ sarr_soa() [2/4]

template<typename T , sarr_soa_detail::size_type N>
gaia::cnt::sarr_soa< T, N >::sarr_soa ( std::initializer_list< T il)
inline

Constructs a container from an initializer list.

Parameters
ilInitializer list supplying the elements.

◆ sarr_soa() [3/4]

template<typename T , sarr_soa_detail::size_type N>
gaia::cnt::sarr_soa< T, N >::sarr_soa ( const sarr_soa< T, N > &  other)
inline

Copy-constructs a container.

Parameters
otherContainer to copy or move from.

◆ sarr_soa() [4/4]

template<typename T , sarr_soa_detail::size_type N>
gaia::cnt::sarr_soa< T, N >::sarr_soa ( sarr_soa< T, N > &&  other)
inlinenoexcept

Move-constructs a container.

Parameters
otherContainer to copy or move from.

Member Function Documentation

◆ back() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::back ( ) const
inlinenoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ back() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::back ( )
inlinenoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ begin() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::begin ( ) const
inlinenoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ begin() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::begin ( )
inlinenoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ capacity()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD constexpr size_type gaia::cnt::sarr_soa< T, N >::capacity ( ) const
inlineconstexprnoexcept

Returns the number of elements that fit without reallocation.

Returns
Current element capacity.

◆ cbegin()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::cbegin ( ) const
inlinenoexcept

Returns a read-only iterator to the first element.

Returns
Iterator to the first element.

◆ cend()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::cend ( ) const
inlinenoexcept

Returns a read-only iterator one past the last element.

Returns
Iterator one past the last element.

◆ crbegin()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::crbegin ( ) const
inlinenoexcept

Returns a read-only reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ crend()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::crend ( ) const
inlinenoexcept

Returns the read-only reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ data() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD const_pointer gaia::cnt::sarr_soa< T, N >::data ( ) const
inlinenoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ data() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD pointer gaia::cnt::sarr_soa< T, N >::data ( )
inlinenoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ empty()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD constexpr bool gaia::cnt::sarr_soa< T, N >::empty ( ) const
inlineconstexprnoexcept

Checks whether the container has no elements.

Returns
True if the container contains no elements.

◆ end() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::end ( ) const
inlinenoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ end() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::end ( )
inlinenoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ front() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::front ( ) const
inlinenoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ front() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::front ( )
inlinenoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ max_size()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD constexpr size_type gaia::cnt::sarr_soa< T, N >::max_size ( ) const
inlineconstexprnoexcept

Returns the maximum number of elements supported by this container.

Returns
Maximum supported element count.

◆ operator!=()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sarr_soa< T, N >::operator!= ( const sarr_soa< T, N > &  other) const
inline

Checks whether two containers differ.

Parameters
otherContainer to copy or move from.
Returns
True if the containers differ.

◆ operator=() [1/3]

template<typename T , sarr_soa_detail::size_type N>
sarr_soa & gaia::cnt::sarr_soa< T, N >::operator= ( const sarr_soa< T, N > &  other)
inline

Copy-assigns the container.

Parameters
otherContainer to copy or move from.
Returns
Reference to this container.

◆ operator=() [2/3]

template<typename T , sarr_soa_detail::size_type N>
sarr_soa & gaia::cnt::sarr_soa< T, N >::operator= ( sarr_soa< T, N > &&  other)
inlinenoexcept

Move-assigns the container.

Parameters
otherContainer to copy or move from.
Returns
Reference to this container.

◆ operator=() [3/3]

template<typename T , sarr_soa_detail::size_type N>
sarr_soa & gaia::cnt::sarr_soa< T, N >::operator= ( std::initializer_list< T il)
inline

Replaces the elements from an initializer list.

Parameters
ilInitializer list supplying the elements.
Returns
Reference to this container.

◆ operator==()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD bool gaia::cnt::sarr_soa< T, N >::operator== ( const sarr_soa< T, N > &  other) const
inline

Compares two containers element by element.

Parameters
otherContainer to copy or move from.
Returns
True if both containers contain equal elements.

◆ operator[]() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::operator[] ( size_type  pos) const
inlinenoexcept

Accesses an element without bounds checking in optimized builds.

Parameters
posZero-based element index.
Returns
Reference to the selected element.

◆ operator[]() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD decltype(auto) gaia::cnt::sarr_soa< T, N >::operator[] ( size_type  pos)
inlinenoexcept

Accesses an element without bounds checking in optimized builds.

Parameters
posZero-based element index.
Returns
Reference to the selected element.

◆ rbegin() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::rbegin ( ) const
inlinenoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rbegin() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::rbegin ( )
inlinenoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rend() [1/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::rend ( ) const
inlinenoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ rend() [2/2]

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD auto gaia::cnt::sarr_soa< T, N >::rend ( )
inlinenoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ size()

template<typename T , sarr_soa_detail::size_type N>
GAIA_NODISCARD constexpr size_type gaia::cnt::sarr_soa< T, N >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements.

Returns
Current element count.

◆ view()

template<typename T , sarr_soa_detail::size_type N>
template<size_t Item>
auto gaia::cnt::sarr_soa< T, N >::view ( ) const
inlinenoexcept

Returns a read-only view of one structure-of-arrays member.

Template Parameters
ItemZero-based member index in the structure-of-arrays element.
Returns
Read-only view of the selected member.

◆ view_mut()

template<typename T , sarr_soa_detail::size_type N>
template<size_t Item>
auto gaia::cnt::sarr_soa< T, N >::view_mut ( )
inlinenoexcept

Returns a mutable view of one structure-of-arrays member.

Template Parameters
ItemZero-based member index in the structure-of-arrays element.
Returns
Mutable view of the selected member.

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