siplasplas
A library for C++ reflection and introspection
|
Represents a type erased function call argument. More...
#include <siplasplas/typeerasure/anyarg.hpp>
Public Member Functions | |
template<typename T , typename = std::enable_if_t< !std::is_same<std::decay_t<T>, cpp::ConstReferenceSimpleAny>::value && !std::is_same<std::decay_t<T>, cpp::ReferenceSimpleAny>::value >> | |
AnyArg (T &&value) | |
Initializes an AnyArg object with a given value. | |
AnyArg (const cpp::ReferenceSimpleAny &reference) | |
AnyArg (const cpp::ConstReferenceSimpleAny &reference) | |
template<typename T > | |
const T & | get () const |
Returns a const reference to the argument object. More... | |
template<typename T > | |
T & | get () |
Returns a reference to the argument object. More... | |
bool | isRvalue () const |
Checks if the argument was an rvalue. | |
bool | isLvalue () const |
Checks if the argument was an lvalue. | |
bool | isConst () const |
Checks if the argument was const. | |
Represents a type erased function call argument.
cpp::SimpleAny and cpp::Any classes represent type erased values that are owned by the any object, except explicitly stated by using Reference
family of specializations. That means that when a normal any class is initialized with an lvalue, the value is copied into the any object. While this works for heterogeneous containers, that semantics doesn't fit the semantics expected on a function call, where parameters taking references alias existing objects.
AnyArg implements the semantics of a function call following two rules:
|
inline |
Returns a const reference to the argument object.
T | Type of the argument (cv qualifiers and references are ignored). The behavior is undefined if T is not the original type of the argument |
|
inline |
Returns a reference to the argument object.
T | Type of the argument (cv qualifiers and references are ignored). The behavior is undefined if T is not the original type of the argument The behavior is also undefined if this get() overload is called and the argument is const lvalue reference (See isConst() and isLvalue()) |