cubos::core::memory::AnyVector class final

Stores a dynamically sized array of blobs of a given reflected type.

Constructors, destructors, conversion operators

AnyVector(const reflection::Type& elementType)
Constructs with the given element type.
AnyVector(AnyVector&& other) noexcept
Move constructs.

Public functions

auto elementType() const -> const reflection::Type&
Get the type of the elements stored in the vector.
void reserve(std::size_t capacity)
Reserves space for at least capacity elements.
void pushUninit()
Pushes an uninitialized element to the back of the vector.
void pushDefault()
Pushes a new default-constructed element to the back of the vector.
void pushCopy(const void* value)
Pushes a new copy-constructed element to the back of the vector.
void pushMove(void* value)
Pushes a new move-constructed element to the back of the vector.
void setDefault(std::size_t index)
Overwrites the element at the given index with a new default-constructed element.
void setCopy(std::size_t index, const void* value)
Overwrites the element at the given index with a new copy-constructed element.
void setMove(std::size_t index, void* value)
Overwrites the element at the given index with a new move-constructed element.
void pop()
Removes the last element from the vector.
void swapErase(std::size_t index)
Removes the element at the given index from the vector, moving the last element to its place if it isn't the last element.
void swapMove(std::size_t index, void* destination)
Moves the element at the given index from the vector into the given address, moving the last element to its place if it isn't the last element.
void clear()
Removes all elements from the vector.
auto at(std::size_t index) -> void*
Get the element at the given index.
auto at(std::size_t index) const -> const void*
Get the element at the given index.
auto size() const -> std::size_t
Get the number of elements in the vector.
auto capacity() const -> std::size_t
Get the number of elements the vector can hold without reallocating.
auto empty() const -> bool
Checks if the vector is empty.

Function documentation

cubos::core::memory::AnyVector::AnyVector(const reflection::Type& elementType)

Constructs with the given element type.

Parameters
elementType Element type.

cubos::core::memory::AnyVector::AnyVector(AnyVector&& other) noexcept

Move constructs.

Parameters
other Vector.

const reflection::Type& cubos::core::memory::AnyVector::elementType() const

Get the type of the elements stored in the vector.

Returns Element type.

void cubos::core::memory::AnyVector::reserve(std::size_t capacity)

Reserves space for at least capacity elements.

Parameters
capacity Minimum capacity.

void cubos::core::memory::AnyVector::pushUninit()

Pushes an uninitialized element to the back of the vector.

void cubos::core::memory::AnyVector::pushDefault()

Pushes a new default-constructed element to the back of the vector.

void cubos::core::memory::AnyVector::pushCopy(const void* value)

Pushes a new copy-constructed element to the back of the vector.

Parameters
value Element to copy.

void cubos::core::memory::AnyVector::pushMove(void* value)

Pushes a new move-constructed element to the back of the vector.

Parameters
value Element to move.

void cubos::core::memory::AnyVector::setDefault(std::size_t index)

Overwrites the element at the given index with a new default-constructed element.

Parameters
index Element index.

void cubos::core::memory::AnyVector::setCopy(std::size_t index, const void* value)

Overwrites the element at the given index with a new copy-constructed element.

Parameters
index Element index.
value Element to copy.

void cubos::core::memory::AnyVector::setMove(std::size_t index, void* value)

Overwrites the element at the given index with a new move-constructed element.

Parameters
index Element index.
value Element to move.

void cubos::core::memory::AnyVector::pop()

Removes the last element from the vector.

void cubos::core::memory::AnyVector::swapErase(std::size_t index)

Removes the element at the given index from the vector, moving the last element to its place if it isn't the last element.

Parameters
index Element index.

void cubos::core::memory::AnyVector::swapMove(std::size_t index, void* destination)

Moves the element at the given index from the vector into the given address, moving the last element to its place if it isn't the last element.

Parameters
index Element index.
destination Address to move the element to.

void* cubos::core::memory::AnyVector::at(std::size_t index)

Get the element at the given index.

Parameters
index Index of the element to get.
Returns Pointer to the element.

const void* cubos::core::memory::AnyVector::at(std::size_t index) const

Get the element at the given index.

Parameters
index Index of the element to get.
Returns Pointer to the element.

std::size_t cubos::core::memory::AnyVector::size() const

Get the number of elements in the vector.

Returns Element count.

std::size_t cubos::core::memory::AnyVector::capacity() const

Get the number of elements the vector can hold without reallocating.

Returns Element capacity.

bool cubos::core::memory::AnyVector::empty() const

Checks if the vector is empty.

Returns Whether the vector is empty.