class final
#include <core/reflection/traits/array.hpp>
ArrayTrait Exposes array-like functionality of a type.
Public types
- using Length = std::size_t(*)(const void*instance)
- Function pointer to get the length of an array instance.
- using AddressOf = uintptr_t(*)(const void*instance, std::size_t index)
- Function pointer to get the address of an element in an array instance.
- using InsertDefault = void(*)(void*instance, std::size_t index)
- Function pointer to insert a default value into the array.
- using InsertCopy = void(*)(void*instance, std::size_t index, const void*value)
- Function pointer to insert a copy of the given value into the array.
- using InsertMove = void(*)(void*instance, std::size_t index, void*value)
- Function pointer to move the given value into the array.
- using Erase = void(*)(void*instance, std::size_t index)
- Function pointer to remove an element of the array.
Constructors, destructors, conversion operators
- ArrayTrait(const Type& elementType, Length length, AddressOf addressOf)
- Constructs.
- View(const ArrayTrait& trait, void* instance)
- Constructs.
- ConstView(const ArrayTrait& trait, const void* instance)
- Constructs.
- Iterator(const View& view, std::size_t index)
- Constructs.
- Iterator(const Iterator& iterator) defaulted
- Copy constructs.
- Iterator(const ConstView& view, std::size_t index)
- Constructs.
- Iterator(const Iterator& iterator) defaulted
- Copy constructs.
Public functions
- void setInsertDefault(InsertDefault insertDefault)
- Sets the default-construct insert operation to the trait.
- void setInsertCopy(InsertCopy insertCopy)
- Sets the copy-construct insert operation to the trait.
- void setInsertMove(InsertMove insertMove)
- Sets the move-construct insert operation to the trait.
- void setErase(Erase erase)
- Sets the erase operation to the trait.
- auto hasInsertDefault() const -> bool
- Checks if default-construct insert is supported.
- auto hasInsertCopy() const -> bool
- Checks if copy-construct insert is supported.
- auto hasInsertMove() const -> bool
- Checks if move-construct insert is supported.
- auto hasErase() const -> bool
- Checks if erase is supported.
- auto hasResize() const -> bool
- Checks if resize is supported.
- auto elementType() const -> const Type&
- Returns the element type of the array.
- auto view(void* instance) const -> View
- Returns a view of the given array instance.
- auto view(const void* instance) const -> ConstView
- Returns a view of the given array instance.
- auto length() const -> std::size_t
- Returns the length of the array.
- auto get(std::size_t index) const -> void*
- Gets a pointer to the element with the given index.
- void insertDefault(std::size_t index) const
- Inserts a default-constructed element.
- void insertCopy(std::size_t index, const void* value) const
- Inserts a copy-constructed element.
- void insertMove(std::size_t index, void* value) const
- Inserts a move-constructed element.
- void erase(std::size_t index) const
- Removes an element.
- void clear() const
- Clears the array.
- void resize(std::size_t size) const
- Resizes the array. If this increases the size of the array, insertDefault is used to insert the remaining elements.
- auto begin() const -> Iterator
- Gets an iterator to the first element.
- auto end() const -> Iterator
- Gets an iterator to the element after the last element.
- auto length() const -> std::size_t
- Returns the length of the array.
- auto get(std::size_t index) const -> const void*
- Gets a pointer to the element with the given index.
- auto begin() const -> Iterator
- Gets an iterator to the first element.
- auto end() const -> Iterator
- Gets an iterator to the element after the last element.
- auto operator*() const -> void*
- Accesses the element referenced by this iterator.
- auto operator->() const -> void*
- Accesses the element referenced by this iterator.
- auto operator++() -> Iterator&
- Advances the iterator.
- auto operator*() const -> const void*
- Accesses the element referenced by this iterator.
- auto operator->() const -> const void*
- Accesses the element referenced by this iterator.
- auto operator++() -> Iterator&
- Advances the iterator.
Function documentation
cubos:: core:: reflection:: ArrayTrait:: ArrayTrait(const Type& elementType,
Length length,
AddressOf addressOf)
Constructs.
Parameters | |
---|---|
elementType | |
length | Function used to get the length of an array. |
addressOf | Function used to address an element in an array. |
cubos:: core:: reflection:: ArrayTrait:: View(const ArrayTrait& trait,
void* instance)
Constructs.
Parameters | |
---|---|
trait | Trait. |
instance | Instance. |
cubos:: core:: reflection:: ArrayTrait:: ConstView(const ArrayTrait& trait,
const void* instance)
Constructs.
Parameters | |
---|---|
trait | Trait. |
instance | Instance. |
cubos:: core:: reflection:: ArrayTrait:: Iterator(const Iterator& iterator) defaulted
Copy constructs.
Parameters | |
---|---|
iterator | Iterator. |
cubos:: core:: reflection:: ArrayTrait:: Iterator(const Iterator& iterator) defaulted
Copy constructs.
Parameters | |
---|---|
iterator | Iterator. |
void cubos:: core:: reflection:: ArrayTrait:: setInsertDefault(InsertDefault insertDefault)
Sets the default-construct insert operation to the trait.
Parameters | |
---|---|
insertDefault | Function pointer. |
void cubos:: core:: reflection:: ArrayTrait:: setInsertCopy(InsertCopy insertCopy)
Sets the copy-construct insert operation to the trait.
Parameters | |
---|---|
insertCopy | Function pointer. |
void cubos:: core:: reflection:: ArrayTrait:: setInsertMove(InsertMove insertMove)
Sets the move-construct insert operation to the trait.
Parameters | |
---|---|
insertMove | Function pointer. |
bool cubos:: core:: reflection:: ArrayTrait:: hasInsertDefault() const
Checks if default-construct insert is supported.
Returns | Whether the operation is supported. |
---|
bool cubos:: core:: reflection:: ArrayTrait:: hasInsertCopy() const
Checks if copy-construct insert is supported.
Returns | Whether the operation is supported. |
---|
bool cubos:: core:: reflection:: ArrayTrait:: hasInsertMove() const
Checks if move-construct insert is supported.
Returns | Whether the operation is supported. |
---|
bool cubos:: core:: reflection:: ArrayTrait:: hasErase() const
Checks if erase is supported.
Returns | Whether the operation is supported. |
---|
bool cubos:: core:: reflection:: ArrayTrait:: hasResize() const
Checks if resize is supported.
Returns | Whether the operation is supported. |
---|
const Type& cubos:: core:: reflection:: ArrayTrait:: elementType() const
Returns the element type of the array.
Returns | Element type. |
---|
std::size_t cubos:: core:: reflection:: ArrayTrait:: length() const
Returns the length of the array.
Returns | Array length. |
---|
void* cubos:: core:: reflection:: ArrayTrait:: get(std::size_t index) const
Gets a pointer to the element with the given index.
Parameters | |
---|---|
index | Element index. |
Returns | Pointer to the element. |
void cubos:: core:: reflection:: ArrayTrait:: insertDefault(std::size_t index) const
Inserts a default-constructed element.
Parameters | |
---|---|
index | Element index. |
void cubos:: core:: reflection:: ArrayTrait:: insertCopy(std::size_t index,
const void* value) const
Inserts a copy-constructed element.
Parameters | |
---|---|
index | Element index. |
value | Value. |
void cubos:: core:: reflection:: ArrayTrait:: insertMove(std::size_t index,
void* value) const
Inserts a move-constructed element.
Parameters | |
---|---|
index | Element index. |
value | Value. |
void cubos:: core:: reflection:: ArrayTrait:: erase(std::size_t index) const
Removes an element.
Parameters | |
---|---|
index | Element index. |
void cubos:: core:: reflection:: ArrayTrait:: clear() const
Clears the array.
void cubos:: core:: reflection:: ArrayTrait:: resize(std::size_t size) const
Resizes the array. If this increases the size of the array, insertDefault is used to insert the remaining elements.
Parameters | |
---|---|
size | Array size. |
std::size_t cubos:: core:: reflection:: ArrayTrait:: length() const
Returns the length of the array.
Returns | Array length. |
---|
const void* cubos:: core:: reflection:: ArrayTrait:: get(std::size_t index) const
Gets a pointer to the element with the given index.
Parameters | |
---|---|
index | Element index. |
Returns | Pointer to the element. |
void* cubos:: core:: reflection:: ArrayTrait:: operator*() const
Accesses the element referenced by this iterator.
Returns | Element. |
---|
void* cubos:: core:: reflection:: ArrayTrait:: operator->() const
Accesses the element referenced by this iterator.
Returns | Element. |
---|
Iterator& cubos:: core:: reflection:: ArrayTrait:: operator++()
Advances the iterator.
Returns | Reference to this. |
---|
const void* cubos:: core:: reflection:: ArrayTrait:: operator*() const
Accesses the element referenced by this iterator.
Returns | Element. |
---|
const void* cubos:: core:: reflection:: ArrayTrait:: operator->() const
Accesses the element referenced by this iterator.
Returns | Element. |
---|
Iterator& cubos:: core:: reflection:: ArrayTrait:: operator++()
Advances the iterator.
Returns | Reference to this. |
---|