ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
toy::FixedVector< type, allocatedSize > Class Template Reference

Public Types

using value_type = type
 Type of elements stored in the vector.
using size_type = size_t
 Type used for vector size and capacity.
using difference_type = std::ptrdiff_t
 Type used for pointer differences.
using reference = value_type &
 Reference to vector element.
using const_reference = const value_type &
 Const reference to vector element.
using pointer = type *
 Pointer to vector element.
using const_pointer = const type *
 Const pointer to vector element.
using iterator = value_type *
 Iterator type for vector elements.
using const_iterator = const value_type *
 Const iterator type for vector elements.
using reverse_iterator = std::reverse_iterator<iterator>
 Reverse iterator type for vector elements.
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 Const reverse iterator type for vector elements.

Public Member Functions

constexpr FixedVector () noexcept
 Default constructor.
constexpr ~FixedVector () noexcept
 Destructor for the vector.
 FixedVector (size_type count)
 Constructs a FixedVector with count default-initialized elements.
 FixedVector (size_type count, const type &value)
 Constructs a FixedVector with count elements initialized to value.
template<typename InputIterator>
 FixedVector (InputIterator first, InputIterator last)
 Constructs a FixedVector from a range defined by iterators.
 FixedVector (const FixedVector< type, allocatedSize > &other) noexcept
 Constructs a copy of other FixedVector.
template<size_t allocatedSize2>
 FixedVector (const FixedVector< type, allocatedSize2 > &other) noexcept
 Constructs a FixedVector by copying from another FixedVector with different capacity.
 FixedVector (FixedVector< type, allocatedSize > &&other) noexcept
 Constructs a FixedVector by moving from another FixedVector.
template<size_t allocatedSize2>
 FixedVector (FixedVector< type, allocatedSize2 > &&other) noexcept
 Constructs a FixedVector by moving from another FixedVector with different capacity.
 FixedVector (std::initializer_list< type > init)
 Constructs a FixedVector from an initializer list.
FixedVector< type, allocatedSize > & operator= (const FixedVector< type, allocatedSize > &other) noexcept
 Copy assigns other FixedVector to this FixedVector.
template<size_t allocatedSize2>
FixedVector< type, allocatedSize > & operator= (const FixedVector< type, allocatedSize2 > &other) noexcept
 Copy assigns FixedVector with different capacity to this FixedVector.
FixedVector< type, allocatedSize > & operator= (FixedVector< type, allocatedSize > &&other) noexcept
 Move assigns other FixedVector to this FixedVector.
template<size_t allocatedSize2>
FixedVector< type, allocatedSize > & operator= (FixedVector< type, allocatedSize2 > &&other) noexcept
 Move assigns FixedVector with different capacity to this FixedVector.
FixedVector< type, allocatedSize > & operator= (std::initializer_list< type > ilist)
 Assigns initializer list to this FixedVector.
void assign (size_type count, const type &value)
 Assigns count copies of value to the vector.
template<typename InputIterator>
void assign (InputIterator first, InputIterator last)
 Assigns elements from the range [ first, last ) to the vector.
void assign (std::initializer_list< type > ilist)
 Assigns elements from an initializer list to the vector.
constexpr reference at (size_type pos) noexcept
 Access an element at the specified position.
constexpr const_reference at (size_type pos) const noexcept
 Access an element at the specified position.
constexpr reference operator[] (size_type pos) noexcept
 Access an element at the specified position.
constexpr const_reference operator[] (size_type pos) const noexcept
 Access an element at the specified position.
constexpr reference front () noexcept
 Returns a reference to the first element of the vector.
constexpr const_reference front () const noexcept
 Returns a const reference to the first element of the vector.
constexpr reference back () noexcept
 Returns a reference to the last element of the vector.
constexpr const_reference back () const noexcept
 Returns a const reference to the last element of the vector.
constexpr pointer data () noexcept
 Returns a pointer to the underlying data array.
constexpr const_pointer data () const noexcept
 Returns a const pointer to the underlying data array.
constexpr iterator begin () noexcept
 Returns an iterator to the first element of the vector.
constexpr const_iterator begin () const noexcept
 Returns a const iterator to the first element of the vector.
constexpr const_iterator cbegin () const noexcept
 Returns a const iterator to the first element of the vector.
constexpr iterator end () noexcept
 Returns an iterator to the element following the last element of the vector.
constexpr const_iterator end () const noexcept
 Returns a const iterator to the element following the last element of the vector.
constexpr const_iterator cend () const noexcept
 Returns a const iterator to the element following the last element of the vector.
constexpr reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the last element of the vector.
constexpr const_reverse_iterator rbegin () const noexcept
 Returns a const reverse iterator to the last element of the vector.
constexpr const_reverse_iterator crbegin () const noexcept
 Returns a const reverse iterator to the last element of the vector.
constexpr reverse_iterator rend () noexcept
 Returns a reverse iterator to the element preceding the first element of the vector.
constexpr const_reverse_iterator rend () const noexcept
 Returns a const reverse iterator to the element preceding the first element of the vector.
constexpr const_reverse_iterator crend () const noexcept
 Returns a const reverse iterator to the element preceding the first element of the vector.
constexpr bool empty () const noexcept
 Checks if the vector is empty.
constexpr size_type size () const noexcept
 Returns the number of elements currently stored in the vector.
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the vector can hold.
constexpr size_type capacity () const noexcept
 Returns the maximum number of elements that can be stored in the vector.
constexpr void clear () noexcept
 Removes all elements from the vector.
constexpr void push_back (const type &val) noexcept

Private Attributes

byte _data [allocatedSize *sizeof(type)]
 Internal buffer for storing elements.
size_type _size = 0
 Current number of elements in the vector.

Member Typedef Documentation

◆ const_iterator

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::const_iterator = const value_type *

Const iterator type for vector elements.

◆ const_pointer

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::const_pointer = const type *

Const pointer to vector element.

◆ const_reference

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::const_reference = const value_type &

Const reference to vector element.

◆ const_reverse_iterator

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Const reverse iterator type for vector elements.

◆ difference_type

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::difference_type = std::ptrdiff_t

Type used for pointer differences.

◆ iterator

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::iterator = value_type *

Iterator type for vector elements.

◆ pointer

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::pointer = type *

Pointer to vector element.

◆ reference

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::reference = value_type &

Reference to vector element.

◆ reverse_iterator

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::reverse_iterator = std::reverse_iterator<iterator>

Reverse iterator type for vector elements.

◆ size_type

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::size_type = size_t

Type used for vector size and capacity.

◆ value_type

template<typename type, size_t allocatedSize>
using toy::FixedVector< type, allocatedSize >::value_type = type

Type of elements stored in the vector.

Constructor & Destructor Documentation

◆ FixedVector() [1/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( )
constexprnoexcept

Default constructor.

Postcondition
The vector is empty and ready for use.

◆ ~FixedVector()

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::~FixedVector ( )
constexprnoexcept

Destructor for the vector.

This destructor cleans up the vector.

Note
Since the FixedVector manages its own elements, proper cleanup is performed.

◆ FixedVector() [2/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( size_type count)
inlineexplicit

Constructs a FixedVector with count default-initialized elements.

This constructor creates a FixedVector containing count elements, each initialized with the default value of type.

Parameters
countThe number of elements to create.
Precondition
The count must not exceed the allocated capacity.
Postcondition
The vector contains count elements, each initialized with the default value of type.
The vector size is equal to count.

◆ FixedVector() [3/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( size_type count,
const type & value )
inline

Constructs a FixedVector with count elements initialized to value.

This constructor creates a FixedVector containing count elements, each initialized with the specified value.

Parameters
countThe number of elements to create.
valueThe value to initialize all elements with.
Precondition
The count must not exceed the allocated capacity.
The value must be a valid instance of type.
Postcondition
The vector contains count elements, each initialized with value.
The vector size is equal to count.

◆ FixedVector() [4/9]

template<typename type, size_t allocatedSize>
template<typename InputIterator>
toy::FixedVector< type, allocatedSize >::FixedVector ( InputIterator first,
InputIterator last )
inline

Constructs a FixedVector from a range defined by iterators.

This constructor initializes a FixedVector with elements from the range [ first, last ).

Template Parameters
InputIteratorThe type of the input iterator. Must not be an integral type.
Parameters
firstIterator pointing to the first element to copy.
lastIterator pointing to one past the last element to copy.
Precondition
The first and last iterators must be valid.
The range [ first, last ) must not exceed the allocated capacity.
All elements in the range must be valid instances of type.
Postcondition
The new vector contains all elements from the range [ first, last ).

◆ FixedVector() [5/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( const FixedVector< type, allocatedSize > & other)
inlinenoexcept

Constructs a copy of other FixedVector.

This constructor initializes a FixedVector by copying the content from another FixedVector of the same type and capacity.

Parameters
otherThe source FixedVector to copy content from.
Precondition
The source other must be valid and properly initialized.
Postcondition
The new vector has the same size and content as the source other.

◆ FixedVector() [6/9]

template<typename type, size_t allocatedSize>
template<size_t allocatedSize2>
toy::FixedVector< type, allocatedSize >::FixedVector ( const FixedVector< type, allocatedSize2 > & other)
inlinenoexcept

Constructs a FixedVector by copying from another FixedVector with different capacity.

This constructor initializes a FixedVector by copying the content from another FixedVector of the same type but potentially different capacity.

Template Parameters
allocatedSize2The capacity of the source FixedVector. Must be greater than zero.
Parameters
otherThe source FixedVector to copy content from.
Precondition
The source other must be valid and properly initialized.
The source other size must not exceed the allocated capacity of this vector.
Postcondition
The new vector has the same size and content as the source other.

◆ FixedVector() [7/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( FixedVector< type, allocatedSize > && other)
inlinenoexcept

Constructs a FixedVector by moving from another FixedVector.

This constructor initializes a FixedVector by moving the content from another FixedVector of the same type and capacity. The source vector is left in a valid but unspecified state.

Parameters
otherThe source FixedVector to move content from.
Precondition
The source other must be valid and properly initialized.
Postcondition
The new vector has the same size and content as the source other.
The source other is left in a valid but unspecified state.

◆ FixedVector() [8/9]

template<typename type, size_t allocatedSize>
template<size_t allocatedSize2>
toy::FixedVector< type, allocatedSize >::FixedVector ( FixedVector< type, allocatedSize2 > && other)
inlinenoexcept

Constructs a FixedVector by moving from another FixedVector with different capacity.

This constructor initializes a FixedVector by moving the content from another FixedVector of the same type but potentially different capacity. The source vector is left in a valid but unspecified state.

Template Parameters
allocatedSize2The capacity of the source FixedVector. Must be greater than zero.
Parameters
otherThe source FixedVector to move content from.
Precondition
The source other must be valid and properly initialized.
The source other size must not exceed the allocated capacity of this vector.
Postcondition
The new vector has the same size and content as the source other.
The source other is left in a valid but unspecified state.

◆ FixedVector() [9/9]

template<typename type, size_t allocatedSize>
toy::FixedVector< type, allocatedSize >::FixedVector ( std::initializer_list< type > init)
inlineexplicit

Constructs a FixedVector from an initializer list.

This constructor initializes a FixedVector with the elements from the provided initializer list.

Parameters
initThe initializer list containing the elements to initialize the vector with.
Precondition
The init size must not exceed the allocated capacity.
All elements in init must be valid instances of type.
Postcondition
The new vector has the same size and content as the source init.

Member Function Documentation

◆ assign() [1/3]

template<typename type, size_t allocatedSize>
template<typename InputIterator>
void toy::FixedVector< type, allocatedSize >::assign ( InputIterator first,
InputIterator last )
inline

Assigns elements from the range [ first, last ) to the vector.

This method replaces the current contents of the vector with elements from the range [ first, last ).

Template Parameters
InputIteratorThe type of the input iterator. Must not be an integral type.
Parameters
firstIterator pointing to the first element to assign.
lastIterator pointing to one past the last element to assign.
Precondition
The first and last iterators must be valid.
The range [ first, last ) must not exceed the allocated capacity.
Postcondition
The vector contains all elements from the range [ first, last ).
The vector size is equal to the size of the range.
All previous elements are properly destroyed.
Note
This method clears existing elements before assignment.
Elements from the range are copied into the vector.

◆ assign() [2/3]

template<typename type, size_t allocatedSize>
void toy::FixedVector< type, allocatedSize >::assign ( size_type count,
const type & value )
inline

Assigns count copies of value to the vector.

This method replaces the current contents of the vector with count copies of value.

Parameters
countThe number of copies of value to assign.
valueThe value to assign count copies of.
Precondition
The count must not exceed the allocated capacity.
Postcondition
The vector contains count elements, each initialized with value.
The vector size is equal to count.
All previous elements are properly destroyed.
Note
This method clears existing elements before assignment.
The value is copied for each element.

◆ assign() [3/3]

template<typename type, size_t allocatedSize>
void toy::FixedVector< type, allocatedSize >::assign ( std::initializer_list< type > ilist)
inline

Assigns elements from an initializer list to the vector.

This method replaces the current contents of the vector with elements from the initializer list.

Parameters
ilistThe initializer list containing the elements to assign.
Precondition
The ilist size must not exceed the allocated capacity.
Postcondition
The vector contains all elements from the initializer list.
The vector size is equal to the size of the initializer list.
All previous elements are properly destroyed.
Note
This method clears existing elements before assignment.
The operator handles empty initializer lists correctly.

◆ at() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reference toy::FixedVector< type, allocatedSize >::at ( size_type pos) const
nodiscardconstexprnoexcept

Access an element at the specified position.

This method provides read-only access to an element at the specified pos.

Parameters
posThe position of the element to access in the vector.
Returns
A const reference to the element at the specified pos.
Precondition
The pos must be less than the current vector size.
Note
The returned reference is read-only and cannot modify the element.
Use the non-const overload to allow modification.
This method is equivalent to the subscript operator.
See also
operator[](size_type pos) const

◆ at() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reference toy::FixedVector< type, allocatedSize >::at ( size_type pos)
nodiscardconstexprnoexcept

Access an element at the specified position.

This method provides direct access to an element at the specified pos.

Parameters
posThe position of the element to access in the vector.
Returns
A reference to the element at the specified pos.
Precondition
The pos must be less than the current vector size.
Note
The returned reference allows modification of the element.
Use const version for read-only access.
This method is equivalent to the subscript operator.
See also
operator[](size_type pos)

◆ back() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reference toy::FixedVector< type, allocatedSize >::back ( ) const
nodiscardconstexprnoexcept

Returns a const reference to the last element of the vector.

This method provides read-only access to the last element of the vector.

Returns
A const reference to the last element of the vector.
Precondition
The vector must not be empty.
Note
The returned reference is read-only and cannot modify the element.
Use the non-const overload to allow modification.
See also
front() const

◆ back() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reference toy::FixedVector< type, allocatedSize >::back ( )
nodiscardconstexprnoexcept

Returns a reference to the last element of the vector.

This method provides direct access to the last element of the vector.

Returns
A reference to the last element of the vector.
Precondition
The vector must not be empty.
Note
The returned reference allows modification of the element.
Use const version for read-only access.
See also
front()

◆ begin() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_iterator toy::FixedVector< type, allocatedSize >::begin ( ) const
nodiscardconstexprnoexcept

Returns a const iterator to the first element of the vector.

This method returns a const iterator pointing to the first element of the vector.

Returns
A const iterator to the first element of the vector.
Note
If the vector is empty, the returned iterator will be equal to end() const.
The iterator is read-only and cannot modify elements.
See also
end() const

◆ begin() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::iterator toy::FixedVector< type, allocatedSize >::begin ( )
nodiscardconstexprnoexcept

Returns an iterator to the first element of the vector.

This method returns an iterator pointing to the first element of the vector.

Returns
An iterator to the first element of the vector.
Note
If the vector is empty, the returned iterator will be equal to end().
The iterator allows modification of elements.
See also
end()

◆ capacity()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::size_type toy::FixedVector< type, allocatedSize >::capacity ( ) const
nodiscardconstexprnoexcept

Returns the maximum number of elements that can be stored in the vector.

This method returns the maximum number of elements that the vector can store without reallocation. This value is fixed at compile time and determined by the template parameter allocatedSize.

Returns
The maximum number of elements the vector can store.
Note
The capacity is always greater than or equal to the current size.
The capacity cannot change during the lifetime of the vector.
Attempting to add more elements than the capacity will result in undefined behavior.
See also
size()

◆ cbegin()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_iterator toy::FixedVector< type, allocatedSize >::cbegin ( ) const
nodiscardconstexprnoexcept

Returns a const iterator to the first element of the vector.

This method returns a const iterator pointing to the first element of the vector.

Returns
A const iterator to the first element of the vector.
Note
If the vector is empty, the returned iterator will be equal to cend().
The iterator is read-only and cannot modify elements.
This method is provided for consistency with standard containers.
See also
cend()

◆ cend()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_iterator toy::FixedVector< type, allocatedSize >::cend ( ) const
nodiscardconstexprnoexcept

Returns a const iterator to the element following the last element of the vector.

This method returns a const iterator pointing to the element following the last element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
A const iterator to the element following the last element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a range [cbegin(), cend()).
For an empty vector, cbegin() == cend().
This method is provided for consistency with standard containers.
See also
cbegin()

◆ clear()

template<typename type, size_t allocatedSize>
void toy::FixedVector< type, allocatedSize >::clear ( )
constexprnoexcept

Removes all elements from the vector.

This method destroys all elements currently stored in the vector and sets the size to zero. The vector can be reused after clearing.

Postcondition
The vector is empty (size is 0).
All elements are properly destroyed.
Note
This method properly destroys each element (destructor calls are optimized away for trivially destructible types).
After calling clear(), the vector can be reused without reallocation.
For POD types, this operation is very fast.
The internal buffer is not deallocated, only elements are destroyed.

◆ crbegin()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reverse_iterator toy::FixedVector< type, allocatedSize >::crbegin ( ) const
nodiscardconstexprnoexcept

Returns a const reverse iterator to the last element of the vector.

This method returns a const reverse iterator pointing to the last element of the vector.

Returns
A const reverse iterator to the last element of the vector.
Note
If the vector is empty, the returned iterator will be equal to crend().
The iterator is read-only and cannot modify elements.
This method is provided for consistency with standard containers.
Iteration through the vector in reverse order can be done using [crbegin(), crend()).
See also
crend()

◆ crend()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reverse_iterator toy::FixedVector< type, allocatedSize >::crend ( ) const
nodiscardconstexprnoexcept

Returns a const reverse iterator to the element preceding the first element of the vector.

This method returns a const reverse iterator pointing to the element preceding the first element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
A const reverse iterator to the element preceding the first element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a reverse range [crbegin(), crend()).
For an empty vector, crbegin() == crend().
This method is provided for consistency with standard containers.
See also
crbegin()

◆ data() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_pointer toy::FixedVector< type, allocatedSize >::data ( ) const
nodiscardconstexprnoexcept

Returns a const pointer to the underlying data array.

This method provides read-only access to the underlying data storage of the vector.

Returns
A const pointer to the first element in the underlying array.
Note
The returned pointer is valid as long as the vector exists.
The pointer points to a contiguous block of memory containing the vector elements.
The array contains exactly size() elements.
The returned pointer does not allow modification of the vector contents.
Warning
Accessing elements beyond size() through the returned pointer results in undefined behavior.
See also
size()

◆ data() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::pointer toy::FixedVector< type, allocatedSize >::data ( )
nodiscardconstexprnoexcept

Returns a pointer to the underlying data array.

This method provides direct access to the underlying data storage of the vector.

Returns
A pointer to the first element in the underlying array.
Note
The returned pointer is valid as long as the vector exists.
The pointer points to a contiguous block of memory containing the vector elements.
The array contains exactly size() elements.
Modifying elements through the returned pointer directly modifies the vector contents.
Use const version for read-only access.
Warning
Accessing elements beyond size() through the returned pointer results in undefined behavior.
See also
size()

◆ empty()

template<typename type, size_t allocatedSize>
bool toy::FixedVector< type, allocatedSize >::empty ( ) const
nodiscardconstexprnoexcept

Checks if the vector is empty.

This method returns whether the vector contains any elements.

Returns
true if the vector is empty (size is 0), false otherwise.
Note
This method provides a convenient way to check if the vector has no elements.
Equivalent to size() == 0.
See also
size()

◆ end() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_iterator toy::FixedVector< type, allocatedSize >::end ( ) const
nodiscardconstexprnoexcept

Returns a const iterator to the element following the last element of the vector.

This method returns a const iterator pointing to the element following the last element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
A const iterator to the element following the last element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a range [begin(), end()).
For an empty vector, begin() const == end() const.
See also
begin() const

◆ end() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::iterator toy::FixedVector< type, allocatedSize >::end ( )
nodiscardconstexprnoexcept

Returns an iterator to the element following the last element of the vector.

This method returns an iterator pointing to the element following the last element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
An iterator to the element following the last element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a range [begin(), end()).
For an empty vector, begin() == end().
See also
begin()

◆ front() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reference toy::FixedVector< type, allocatedSize >::front ( ) const
nodiscardconstexprnoexcept

Returns a const reference to the first element of the vector.

This method provides read-only access to the first element of the vector.

Returns
A const reference to the first element of the vector.
Precondition
The vector must not be empty.
Note
The returned reference is read-only and cannot modify the element.
Use the non-const overload to allow modification.
See also
back() const

◆ front() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reference toy::FixedVector< type, allocatedSize >::front ( )
nodiscardconstexprnoexcept

Returns a reference to the first element of the vector.

This method provides direct access to the first element of the vector.

Returns
A reference to the first element of the vector.
Precondition
The vector must not be empty.
Note
The returned reference allows modification of the element.
Use const version for read-only access.
See also
back()

◆ max_size()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::size_type toy::FixedVector< type, allocatedSize >::max_size ( ) const
nodiscardconstexprnoexcept

Returns the maximum number of elements the vector can hold.

This method returns the theoretical maximum number of elements that the vector can hold. For FixedVector, this is equal to the allocated capacity.

Returns
The maximum number of elements the vector can hold.
Note
For FixedVector, max_size() is always equal to capacity().
This value is fixed at compile time and determined by the template parameter allocatedSize.
See also
capacity()

◆ operator=() [1/5]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize > & toy::FixedVector< type, allocatedSize >::operator= ( const FixedVector< type, allocatedSize > & other)
inlinenoexcept

Copy assigns other FixedVector to this FixedVector.

This operator assigns the contents of another FixedVector with the same capacity to this vector.

Parameters
otherThe FixedVector to copy content from.
Returns
A reference to this FixedVector after assignment.
Precondition
The other vector must be valid and properly constructed.
Postcondition
This vector has the same size and content as the source other vector.
All elements are properly copied using copy construction.
All previous elements are properly destroyed.
Note
Self-assignment is handled correctly and safely.

◆ operator=() [2/5]

template<typename type, size_t allocatedSize>
template<size_t allocatedSize2>
FixedVector< type, allocatedSize > & toy::FixedVector< type, allocatedSize >::operator= ( const FixedVector< type, allocatedSize2 > & other)
inlinenoexcept

Copy assigns FixedVector with different capacity to this FixedVector.

This operator assigns the contents of another FixedVector with different capacity to this vector.

Template Parameters
allocatedSize2The capacity of the source FixedVector.
Parameters
otherThe FixedVector to copy content from.
Returns
A reference to this FixedVector after assignment.
Precondition
The other vector must be valid and properly constructed.
The other vector size must not exceed this vector's capacity.
Postcondition
This vector has the same size and content as the source other vector.
All elements are properly copied using copy construction.
All previous elements are properly destroyed.

◆ operator=() [3/5]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize > & toy::FixedVector< type, allocatedSize >::operator= ( FixedVector< type, allocatedSize > && other)
inlinenoexcept

Move assigns other FixedVector to this FixedVector.

This operator assigns the contents of another FixedVector with the same capacity to this vector using move semantics.

Parameters
otherThe FixedVector to move content from.
Returns
A reference to this FixedVector after assignment.
Precondition
The other vector must be valid and properly constructed.
Postcondition
This vector has the same size and content as the source other vector.
All elements are moved using move construction.
All previous elements are properly destroyed.
The source vector is left in a valid but unspecified state.
Note
Self-assignment is handled correctly and safely.

◆ operator=() [4/5]

template<typename type, size_t allocatedSize>
template<size_t allocatedSize2>
FixedVector< type, allocatedSize > & toy::FixedVector< type, allocatedSize >::operator= ( FixedVector< type, allocatedSize2 > && other)
inlinenoexcept

Move assigns FixedVector with different capacity to this FixedVector.

This operator assigns the contents of another FixedVector with different capacity to this vector using move semantics.

Template Parameters
allocatedSize2The capacity of the source FixedVector.
Parameters
otherThe FixedVector to move content from.
Returns
A reference to this FixedVector after assignment.
Precondition
The other vector must be valid and properly constructed.
The other vector size must not exceed this vector's capacity.
Postcondition
This vector has the same size and content as the source other vector.
All elements are moved using move construction.
All previous elements are properly destroyed.
The source vector is left in a valid but unspecified state.

◆ operator=() [5/5]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize > & toy::FixedVector< type, allocatedSize >::operator= ( std::initializer_list< type > ilist)
inline

Assigns initializer list to this FixedVector.

This operator assigns the contents of an initializer list to this vector.

Parameters
ilistThe initializer list containing the elements to assign.
Returns
A reference to this FixedVector after assignment.
Precondition
The ilist size must not exceed the allocated capacity.
All elements in ilist must be valid instances of type.
Postcondition
This vector has the same size and content as the source ilist.
All elements are properly copied using copy construction.
All previous elements are properly destroyed.
Note
The operator handles empty initializer lists correctly.

◆ operator[]() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reference toy::FixedVector< type, allocatedSize >::operator[] ( size_type pos) const
nodiscardconstexprnoexcept

Access an element at the specified position.

This operator provides read-only access to an element at the specified pos.

Parameters
posThe position of the element to access in the vector.
Returns
A const reference to the element at the specified pos.
Precondition
The pos should be less than the current vector size.
Note
The returned reference is read-only and cannot modify the element.
Use the non-const overload to allow modification.

◆ operator[]() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reference toy::FixedVector< type, allocatedSize >::operator[] ( size_type pos)
nodiscardconstexprnoexcept

Access an element at the specified position.

This operator provides direct access to an element at the specified pos.

Parameters
posThe position of the element to access in the vector.
Returns
A reference to the element at the specified pos.
Precondition
The pos should be less than the current vector size.
Note
The returned reference allows modification of the element.
Use const version for read-only access.

◆ push_back()

template<typename type, size_t allocatedSize>
void toy::FixedVector< type, allocatedSize >::push_back ( const type & val)
constexprnoexcept

◆ rbegin() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reverse_iterator toy::FixedVector< type, allocatedSize >::rbegin ( ) const
nodiscardconstexprnoexcept

Returns a const reverse iterator to the last element of the vector.

This method returns a const reverse iterator pointing to the last element of the vector.

Returns
A const reverse iterator to the last element of the vector.
Note
If the vector is empty, the returned iterator will be equal to rend() const.
The iterator is read-only and cannot modify elements.
Iteration through the vector in reverse order can be done using [rbegin(), rend()) const.
See also
rend() const

◆ rbegin() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reverse_iterator toy::FixedVector< type, allocatedSize >::rbegin ( )
nodiscardconstexprnoexcept

Returns a reverse iterator to the last element of the vector.

This method returns a reverse iterator pointing to the last element of the vector.

Returns
A reverse iterator to the last element of the vector.
Note
If the vector is empty, the returned iterator will be equal to rend().
The iterator allows modification of elements.
Iteration through the vector in reverse order can be done using [rbegin(), rend()).
See also
rend()

◆ rend() [1/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::const_reverse_iterator toy::FixedVector< type, allocatedSize >::rend ( ) const
nodiscardconstexprnoexcept

Returns a const reverse iterator to the element preceding the first element of the vector.

This method returns a const reverse iterator pointing to the element preceding the first element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
A const reverse iterator to the element preceding the first element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a reverse range [rbegin(), rend()) const.
For an empty vector, rbegin() const == rend() const.
See also
rbegin() const

◆ rend() [2/2]

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::reverse_iterator toy::FixedVector< type, allocatedSize >::rend ( )
nodiscardconstexprnoexcept

Returns a reverse iterator to the element preceding the first element of the vector.

This method returns a reverse iterator pointing to the element preceding the first element of the vector. This iterator acts as a placeholder and cannot be dereferenced.

Returns
A reverse iterator to the element preceding the first element of the vector.
Note
The returned iterator should not be dereferenced.
It is used to indicate the end of a reverse range [rbegin(), rend()).
For an empty vector, rbegin() == rend().
See also
rbegin()

◆ size()

template<typename type, size_t allocatedSize>
FixedVector< type, allocatedSize >::size_type toy::FixedVector< type, allocatedSize >::size ( ) const
nodiscardconstexprnoexcept

Returns the number of elements currently stored in the vector.

This method returns the current number of elements in the vector.

Returns
The number of elements in the vector.
Note
The size is always less than or equal to the capacity.
For an empty vector, this method returns 0.
See also
capacity(), empty()

Member Data Documentation

◆ _data

template<typename type, size_t allocatedSize>
byte toy::FixedVector< type, allocatedSize >::_data[allocatedSize *sizeof(type)]
private

Internal buffer for storing elements.

◆ _size

template<typename type, size_t allocatedSize>
size_type toy::FixedVector< type, allocatedSize >::_size = 0
private

Current number of elements in the vector.


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