1 #ifndef SIPLASPLAS_TYPEERASURE_TYPEINFO_HPP 2 #define SIPLASPLAS_TYPEERASURE_TYPEINFO_HPP 4 #include "features/valuesemantics.hpp" 5 #include <siplasplas/utility/memory_manip.hpp> 6 #include <siplasplas/utility/function_traits.hpp> 7 #include <siplasplas/utility/typeinfo.hpp> 8 #include <siplasplas/constexpr/arrayview.hpp> 9 #include <siplasplas/constexpr/meta.hpp> 26 DEFAULT_CONSTRUCT = 0,
35 using ValueSemanticsOperationFunction = void(*)(
void*,
const void*);
61 static ValueSemanticsOperationFunction operations[
static_cast<std::size_t
>(ValueSemanticsOperation::END_OF_ENUM)] = {
62 [](
void* object,
const void*) {
63 features::DefaultConstructible::apply<T>(object);
65 [](
void* object,
const void* other) {
66 features::CopyConstructible::apply<T>(object, other);
68 [](
void* object,
const void* other) {
69 features::MoveConstructible::apply<T>(object,
const_cast<void*
>(other));
71 [](
void* object,
const void* other) {
72 features::CopyAssignable::apply<T>(object, other);
74 [](
void* object,
const void* other) {
75 features::MoveAssignable::apply<T>(object,
const_cast<void*
>(other));
77 [](
void* object,
const void*) {
78 features::Destructible::apply<T>(object);
82 return operations[
static_cast<std::size_t
>(operation)];
85 using ValueSemantics = decltype(&valueSemanticsOperation<int>);
131 return cpp::TypeInfo::isPointer();
140 return semantics()(operation);
151 semantics(detail::ValueSemanticsOperation::DEFAULT_CONSTRUCT)(where,
nullptr);
163 semantics(detail::ValueSemanticsOperation::COPY_CONSTRUCT)(where, other);
176 semantics(detail::ValueSemanticsOperation::MOVE_CONSTRUCT)(where,
const_cast<const void*
>(other));
188 semantics(detail::ValueSemanticsOperation::COPY_ASSIGN)(where, other);
201 semantics(detail::ValueSemanticsOperation::MOVE_ASSIGN)(where,
const_cast<const void*
>(other));
214 semantics(detail::ValueSemanticsOperation::DESTROY)(where,
nullptr);
225 return _functionArgs;
243 return TypeInfo::get<T>();
248 return lhs._semantics == rhs._semantics;
253 return !(lhs == rhs);
257 struct TypeToTypeInfo
264 return TypeInfo::get<T>();
271 _semantics{detail::valueSemanticsOperation<std::decay_t<T>>},
274 cpp::function_arguments<T>,
280 detail::ValueSemantics _semantics;
289 #endif // SIPLASPLAS_TYPEERASURE_TYPEINFO_HPP void moveConstruct(void *where, void *other) const
Move constructs values of the type If the passed arguments are not of the represented type...
Definition: typeinfo.hpp:174
ValueSemanticsOperation
Represents a value semantics operation.
Definition: typeinfo.hpp:24
Definition: arrayview.hpp:87
Definition: messaging.hpp:8
void defaultConstruct(void *where) const
Default constructs a value of the type If the passed argument is not of the represented type...
Definition: typeinfo.hpp:149
void destroy(void *where) const
Destroys objects of the type If the passed arguments are not of the represented type, the behavior is undefined.
Definition: typeinfo.hpp:210
bool isPointer() const
Checks if the type is a pointer type.
Definition: typeinfo.hpp:129
ValueSemanticsOperationFunction valueSemanticsOperation(ValueSemanticsOperation operation)
Implements a type-erased interface for the value semantics features of a type T.
Definition: typeinfo.hpp:59
detail::ValueSemanticsOperationFunction semantics(detail::ValueSemanticsOperation operation) const
Returns the function implementing the given valuesemantics operation for the type.
Definition: typeinfo.hpp:138
Definition: test_util.hpp:13
void moveAssign(void *where, void *other) const
Move assigns values of the type If the passed arguments are not of the represented type...
Definition: typeinfo.hpp:199
Contains minimal information to execute the value semantics operations of a type. ...
Definition: typeinfo.hpp:115
Definition: typeinfo.hpp:13
detail::ValueSemantics semantics() const
Retuns the type-erased semantics of the type.
Definition: typeinfo.hpp:121
constexpr cpp::constexp::ConstArrayView< TypeInfo > arguments() const
Returns the type information of the function arguments.
Definition: typeinfo.hpp:223
void copyConstruct(void *where, const void *other) const
Copy constructs values of the type If the passed arguments are not of the represented type...
Definition: typeinfo.hpp:161
void copyAssign(void *where, const void *other) const
Move assigns values of the type If the passed arguments are not of the represented type...
Definition: typeinfo.hpp:186