cubos::core::reflection::ConstructibleTrait class

Describes how a reflected type may be constructed and destructed.

Public types

template<typename T>
class Builder
Builder for ConstructibleTrait.
using Destructor = void(*)(void*instance)
Function pointer to the destructor of a type.
using DefaultConstructor = void(*)(void*instance)
Function pointer to the default constructor of a type.
using CopyConstructor = void(*)(void*instance, const void*other)
Function pointer to the copy constructor of a type.
using MoveConstructor = void(*)(void*instance, void*other)
Function pointer to the move constructor of a type.

Public static functions

template<typename T>
static auto typed() -> Builder<T>
Returns a trait builder for the given type.

Constructors, destructors, conversion operators

ConstructibleTrait(std::size_t size, std::size_t alignment, void(*)(void*) destructor)
Constructs.

Public functions

auto withDefaultConstructor(DefaultConstructor defaultConstructor) && -> ConstructibleTrait&&
Sets the default constructor of the type.
auto withCopyConstructor(CopyConstructor copyConstructor) && -> ConstructibleTrait&&
Sets the copy constructor of the type.
auto withMoveConstructor(MoveConstructor moveConstructor) && -> ConstructibleTrait&&
Sets the move constructor of the type.
auto size() const -> std::size_t
Returns the size of the type in bytes.
auto alignment() const -> std::size_t
Returns the alignment of the type in bytes.
auto hasDefaultConstruct() const -> bool
Checks if default construction is supported.
auto hasCopyConstruct() const -> bool
Checks if copy construction is supported.
auto hasMoveConstruct() const -> bool
Checks if move construction is supported.
void destruct(void* instance) const
Destructs an instance of the type.
void defaultConstruct(void* instance) const
Default constructs an instance of the type.
void copyConstruct(void* instance, const void* other) const
Copy constructs an instance of the type.
void moveConstruct(void* instance, void* other) const
Move constructs an instance of the type.

Function documentation

template<typename T>
static Builder<T> cubos::core::reflection::ConstructibleTrait::typed()

Returns a trait builder for the given type.

Template parameters
T Type to build a trait for.
Returns Trait builder.

cubos::core::reflection::ConstructibleTrait::ConstructibleTrait(std::size_t size, std::size_t alignment, void(*)(void*) destructor)

Constructs.

Parameters
size Size of the type in bytes.
alignment Alignment of the type in bytes (must be a power of two).
destructor Function pointer to the destructor of the type.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withDefaultConstructor(DefaultConstructor defaultConstructor) &&

Sets the default constructor of the type.

Parameters
defaultConstructor Function pointer to the default constructor of the type.
Returns Trait.

Aborts if the default constructor has already been set.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withCopyConstructor(CopyConstructor copyConstructor) &&

Sets the copy constructor of the type.

Parameters
copyConstructor Function pointer to the copy constructor of the type.
Returns Trait.

Aborts if the copy constructor has already been set.

ConstructibleTrait&& cubos::core::reflection::ConstructibleTrait::withMoveConstructor(MoveConstructor moveConstructor) &&

Sets the move constructor of the type.

Parameters
moveConstructor Function pointer to the move constructor of the type.
Returns Trait.

Aborts if the copy constructor has already been set.

std::size_t cubos::core::reflection::ConstructibleTrait::size() const

Returns the size of the type in bytes.

Returns Size of the type in bytes.

std::size_t cubos::core::reflection::ConstructibleTrait::alignment() const

Returns the alignment of the type in bytes.

Returns Alignment of the type in bytes.

bool cubos::core::reflection::ConstructibleTrait::hasDefaultConstruct() const

Checks if default construction is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::ConstructibleTrait::hasCopyConstruct() const

Checks if copy construction is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::ConstructibleTrait::hasMoveConstruct() const

Checks if move construction is supported.

Returns Whether the operation is supported.

void cubos::core::reflection::ConstructibleTrait::destruct(void* instance) const

Destructs an instance of the type.

Parameters
instance Pointer to the instance to destruct.

void cubos::core::reflection::ConstructibleTrait::defaultConstruct(void* instance) const

Default constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.

void cubos::core::reflection::ConstructibleTrait::copyConstruct(void* instance, const void* other) const

Copy constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.
other Pointer to the instance to copy construct from.

void cubos::core::reflection::ConstructibleTrait::moveConstruct(void* instance, void* other) const

Move constructs an instance of the type.

Parameters
instance Pointer to the location to construct the instance at.
other Pointer to the instance to move construct from.