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

Array of elements of type. More...

#include <sarray_ext_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 = const T *
 Read-only element pointer type.
 
using view_policy = mem::data_view_policy_aos< T >
 Data-layout access policy used by the container.
 
using difference_type = sarr_ext_detail::difference_type
 Type used for iterator differences.
 
using size_type = sarr_ext_detail::size_type
 Unsigned type used for sizes and indices.
 
using iterator = pointer
 Mutable random-access iterator type.
 
using const_iterator = const_pointer
 Read-only random-access iterator type.
 
using iterator_category = core::random_access_iterator_tag
 Iterator category exposed by the container.
 

Public Member Functions

constexpr sarr_ext (core::zero_t) noexcept
 Constructs a value-initialized container.
 
constexpr sarr_ext (size_type count, const_reference value) noexcept
 Constructs a container with copies of a value.
 
constexpr sarr_ext (size_type count) noexcept
 Constructs a container with the requested number of value-initialized elements.
 
template<typename InputIt >
constexpr sarr_ext (InputIt first, InputIt last) noexcept
 Constructs a container from an iterator range.
 
constexpr sarr_ext (std::initializer_list< T > il)
 Constructs a container from an initializer list.
 
constexpr sarr_ext (const sarr_ext &other)
 Copy-constructs a container.
 
constexpr sarr_ext (sarr_ext &&other) noexcept
 Move-constructs a container.
 
sarr_extoperator= (std::initializer_list< T > il)
 Replaces the elements from an initializer list.
 
constexpr sarr_extoperator= (const sarr_ext &other)
 Copy-assigns the container.
 
constexpr sarr_extoperator= (sarr_ext &&other) noexcept
 Move-assigns the container.
 
GAIA_NODISCARD constexpr pointer data () noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD constexpr const_pointer data () const noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD constexpr decltype(autooperator[] (size_type pos) noexcept
 Accesses an element without bounds checking in optimized builds.
 
GAIA_NODISCARD constexpr decltype(autooperator[] (size_type pos) const noexcept
 Accesses an element without bounds checking in optimized builds.
 
constexpr void push_back (const T &arg) noexcept
 Appends an element.
 
constexpr void push_back (T &&arg) noexcept
 Appends an element.
 
template<typename... Args>
constexpr decltype(autoemplace_back (Args &&... args) noexcept
 Constructs and appends an element.
 
constexpr void pop_back () noexcept
 Removes the last element.
 
iterator insert (iterator pos, const T &arg) noexcept
 Insert the element to the position given by iterator pos.
 
iterator insert (iterator pos, T &&arg) noexcept
 Insert the element to the position given by iterator pos.
 
constexpr iterator erase (iterator pos) noexcept
 Removes the element at pos.
 
iterator erase (iterator first, iterator last) noexcept
 Removes the elements in the range [first, last)
 
iterator erase_at (size_type pos) noexcept
 
constexpr void clear () noexcept
 Removes all elements.
 
constexpr void resize (size_type count) noexcept
 Changes the number of elements.
 
constexpr void resize (size_type count, const_reference value) noexcept
 Changes the size and initializes new elements from a value.
 
template<typename Func >
auto retain (Func &&func) noexcept
 Removes all elements that fail the predicate.
 
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 constexpr decltype(autofront () noexcept
 Accesses the first element.
 
GAIA_NODISCARD constexpr decltype(autofront () const noexcept
 Accesses the first element.
 
GAIA_NODISCARD constexpr decltype(autoback () noexcept
 Accesses the last element.
 
GAIA_NODISCARD constexpr decltype(autoback () const noexcept
 Accesses the last element.
 
GAIA_NODISCARD constexpr auto begin () noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD constexpr auto begin () const noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD constexpr auto cbegin () const noexcept
 Returns a read-only iterator to the first element.
 
GAIA_NODISCARD constexpr auto rbegin () noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD constexpr auto rbegin () const noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD constexpr auto crbegin () const noexcept
 Returns a read-only reverse traversal iterator to the last element.
 
GAIA_NODISCARD constexpr auto end () noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD constexpr auto end () const noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD constexpr auto cend () const noexcept
 Returns a read-only iterator one past the last element.
 
GAIA_NODISCARD constexpr auto rend () noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD constexpr auto rend () const noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD constexpr auto crend () const noexcept
 Returns the read-only reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD constexpr bool operator== (const sarr_ext &other) const noexcept
 Compares two containers element by element.
 
GAIA_NODISCARD constexpr bool operator!= (const sarr_ext &other) const noexcept
 Checks whether two containers differ.
 

Static Public Attributes

static constexpr size_t value_size = sizeof(T)
 Size of one element in bytes.
 
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_ext_detail::size_type N>
class gaia::cnt::sarr_ext< T, N >

Array of elements of type.

Template Parameters
Twith fixed capacity
Nand variable size allocated on stack. Interface compatiblity with std::array where it matters.

Constructor & Destructor Documentation

◆ sarr_ext() [1/6]

template<typename T , sarr_ext_detail::size_type N>
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( size_type  count,
const_reference  value 
)
inlineconstexprnoexcept

Constructs a container with copies of a value.

Parameters
countNumber of elements.
valueValue assigned to each new element.

◆ sarr_ext() [2/6]

template<typename T , sarr_ext_detail::size_type N>
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( size_type  count)
inlineconstexprnoexcept

Constructs a container with the requested number of value-initialized elements.

Parameters
countNumber of elements.

◆ sarr_ext() [3/6]

template<typename T , sarr_ext_detail::size_type N>
template<typename InputIt >
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( InputIt  first,
InputIt  last 
)
inlineconstexprnoexcept

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_ext() [4/6]

template<typename T , sarr_ext_detail::size_type N>
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( std::initializer_list< T il)
inlineconstexpr

Constructs a container from an initializer list.

Parameters
ilInitializer list supplying the elements.

◆ sarr_ext() [5/6]

template<typename T , sarr_ext_detail::size_type N>
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( const sarr_ext< T, N > &  other)
inlineconstexpr

Copy-constructs a container.

Parameters
otherContainer to copy or move from.

◆ sarr_ext() [6/6]

template<typename T , sarr_ext_detail::size_type N>
constexpr gaia::cnt::sarr_ext< T, N >::sarr_ext ( sarr_ext< T, N > &&  other)
inlineconstexprnoexcept

Move-constructs a container.

Parameters
otherContainer to copy or move from.

Member Function Documentation

◆ back() [1/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::back ( ) const
inlineconstexprnoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ back() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::back ( )
inlineconstexprnoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ begin() [1/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::begin ( ) const
inlineconstexprnoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ begin() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::begin ( )
inlineconstexprnoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ capacity()

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

Returns the number of elements that fit without reallocation.

Returns
Current element capacity.

◆ cbegin()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::cbegin ( ) const
inlineconstexprnoexcept

Returns a read-only iterator to the first element.

Returns
Iterator to the first element.

◆ cend()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::cend ( ) const
inlineconstexprnoexcept

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

Returns
Iterator one past the last element.

◆ crbegin()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::crbegin ( ) const
inlineconstexprnoexcept

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

Returns
Iterator to the last element.

◆ crend()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::crend ( ) const
inlineconstexprnoexcept

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_ext_detail::size_type N>
GAIA_NODISCARD constexpr const_pointer gaia::cnt::sarr_ext< T, N >::data ( ) const
inlineconstexprnoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ data() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr pointer gaia::cnt::sarr_ext< T, N >::data ( )
inlineconstexprnoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ emplace_back()

template<typename T , sarr_ext_detail::size_type N>
template<typename... Args>
constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::emplace_back ( Args &&...  args)
inlineconstexprnoexcept

Constructs and appends an element.

Template Parameters
ArgsTypes of the forwarded constructor arguments.
Parameters
argsArguments forwarded to the element constructor.
Returns
Reference to the appended element.

◆ empty()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr bool gaia::cnt::sarr_ext< 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_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::end ( ) const
inlineconstexprnoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ end() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::end ( )
inlineconstexprnoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ erase() [1/2]

template<typename T , sarr_ext_detail::size_type N>
iterator gaia::cnt::sarr_ext< T, N >::erase ( iterator  first,
iterator  last 
)
inlinenoexcept

Removes the elements in the range [first, last)

Returns
Iterator to the element following the removed element or range.
Parameters
firstIterator to the element to remove
lastIterator to the one beyond the last element to remove

◆ erase() [2/2]

template<typename T , sarr_ext_detail::size_type N>
constexpr iterator gaia::cnt::sarr_ext< T, N >::erase ( iterator  pos)
inlineconstexprnoexcept

Removes the element at pos.

Returns
Iterator to the element following the removed element or range.
Parameters
posIterator to the element to remove

◆ erase_at()

template<typename T , sarr_ext_detail::size_type N>
iterator gaia::cnt::sarr_ext< T, N >::erase_at ( size_type  pos)
inlinenoexcept
Returns
Iterator to the element following the removed element or range. Removes the element at index
Parameters
pos

◆ front() [1/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::front ( ) const
inlineconstexprnoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ front() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::front ( )
inlineconstexprnoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ insert() [1/2]

template<typename T , sarr_ext_detail::size_type N>
iterator gaia::cnt::sarr_ext< T, N >::insert ( iterator  pos,
const T arg 
)
inlinenoexcept

Insert the element to the position given by iterator pos.

Returns
Iterator to the inserted element.
Parameters
posPosition in the container
argData to insert

◆ insert() [2/2]

template<typename T , sarr_ext_detail::size_type N>
iterator gaia::cnt::sarr_ext< T, N >::insert ( iterator  pos,
T &&  arg 
)
inlinenoexcept

Insert the element to the position given by iterator pos.

Returns
Iterator to the inserted element.
Parameters
posPosition in the container
argData to insert

◆ max_size()

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr size_type gaia::cnt::sarr_ext< 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_ext_detail::size_type N>
GAIA_NODISCARD constexpr bool gaia::cnt::sarr_ext< T, N >::operator!= ( const sarr_ext< T, N > &  other) const
inlineconstexprnoexcept

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_ext_detail::size_type N>
constexpr sarr_ext & gaia::cnt::sarr_ext< T, N >::operator= ( const sarr_ext< T, N > &  other)
inlineconstexpr

Copy-assigns the container.

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

◆ operator=() [2/3]

template<typename T , sarr_ext_detail::size_type N>
constexpr sarr_ext & gaia::cnt::sarr_ext< T, N >::operator= ( sarr_ext< T, N > &&  other)
inlineconstexprnoexcept

Move-assigns the container.

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

◆ operator=() [3/3]

template<typename T , sarr_ext_detail::size_type N>
sarr_ext & gaia::cnt::sarr_ext< 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_ext_detail::size_type N>
GAIA_NODISCARD constexpr bool gaia::cnt::sarr_ext< T, N >::operator== ( const sarr_ext< T, N > &  other) const
inlineconstexprnoexcept

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_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::operator[] ( size_type  pos) const
inlineconstexprnoexcept

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_ext_detail::size_type N>
GAIA_NODISCARD constexpr decltype(auto) gaia::cnt::sarr_ext< T, N >::operator[] ( size_type  pos)
inlineconstexprnoexcept

Accesses an element without bounds checking in optimized builds.

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

◆ push_back() [1/2]

template<typename T , sarr_ext_detail::size_type N>
constexpr void gaia::cnt::sarr_ext< T, N >::push_back ( const T arg)
inlineconstexprnoexcept

Appends an element.

Parameters
argElement value to append.

◆ push_back() [2/2]

template<typename T , sarr_ext_detail::size_type N>
constexpr void gaia::cnt::sarr_ext< T, N >::push_back ( T &&  arg)
inlineconstexprnoexcept

Appends an element.

Parameters
argElement value to append.

◆ rbegin() [1/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::rbegin ( ) const
inlineconstexprnoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rbegin() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::rbegin ( )
inlineconstexprnoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rend() [1/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::rend ( ) const
inlineconstexprnoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ rend() [2/2]

template<typename T , sarr_ext_detail::size_type N>
GAIA_NODISCARD constexpr auto gaia::cnt::sarr_ext< T, N >::rend ( )
inlineconstexprnoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ resize() [1/2]

template<typename T , sarr_ext_detail::size_type N>
constexpr void gaia::cnt::sarr_ext< T, N >::resize ( size_type  count)
inlineconstexprnoexcept

Changes the number of elements.

Parameters
countNumber of elements.

◆ resize() [2/2]

template<typename T , sarr_ext_detail::size_type N>
constexpr void gaia::cnt::sarr_ext< T, N >::resize ( size_type  count,
const_reference  value 
)
inlineconstexprnoexcept

Changes the size and initializes new elements from a value.

Parameters
countNumber of elements.
valueValue assigned to each new element.

◆ retain()

template<typename T , sarr_ext_detail::size_type N>
template<typename Func >
auto gaia::cnt::sarr_ext< T, N >::retain ( Func &&  func)
inlinenoexcept

Removes all elements that fail the predicate.

Template Parameters
FuncPredicate callable type.
Parameters
funcA lambda or a functor with the bool operator()(Container::value_type&) overload.
Returns
The new size of the array.

◆ size()

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

Returns the number of elements.

Returns
Current element count.

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