Clementine
Public Member Functions | Friends | List of all members
entt::meta_any Class Reference

Opaque wrapper for values of any type. More...

#include <entt.hpp>

Public Member Functions

 meta_any () ENTT_NOEXCEPT
 Default constructor.
 
template<typename Type , typename... Args>
 meta_any (std::in_place_type_t< Type >, Args &&... args)
 Constructs a meta any by directly initializing the new object. More...
 
template<typename Type >
 meta_any (std::reference_wrapper< Type > value)
 Constructs a meta any that holds an unmanaged object. More...
 
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>>>
 meta_any (Type &&value)
 Constructs a meta any from a given value. More...
 
 meta_any (const meta_any &other)=default
 Copy constructor. More...
 
 meta_any (meta_any &&other) ENTT_NOEXCEPT
 Move constructor. More...
 
 ~meta_any ()
 Frees the internal storage, whatever it means.
 
meta_anyoperator= (meta_any other)
 Assignment operator. More...
 
meta_type type () const ENTT_NOEXCEPT
 Returns the meta type of the underlying object. More...
 
const void * data () const ENTT_NOEXCEPT
 Returns an opaque pointer to the contained instance. More...
 
void * data () ENTT_NOEXCEPT
 Returns an opaque pointer to the contained instance. More...
 
template<typename... Args>
meta_any invoke (const id_type id, Args &&... args) const
 Invokes the underlying function, if possible. More...
 
template<typename... Args>
meta_any invoke (const id_type id, Args &&... args)
 Invokes the underlying function, if possible. More...
 
template<typename Type >
bool set (const id_type id, Type &&value)
 Sets the value of a given variable. More...
 
meta_any get (const id_type id) const
 Gets the value of a given variable. More...
 
meta_any get (const id_type id)
 Gets the value of a given variable. More...
 
template<typename Type >
const Type * try_cast () const
 Tries to cast an instance to a given type. More...
 
template<typename Type >
Type * try_cast ()
 Tries to cast an instance to a given type. More...
 
template<typename Type >
Type cast () const
 Tries to cast an instance to a given type. More...
 
template<typename Type >
Type cast ()
 Tries to cast an instance to a given type. More...
 
template<typename Type >
meta_any allow_cast () const
 Tries to make an instance castable to a certain type. More...
 
template<typename Type >
bool allow_cast ()
 Tries to make an instance castable to a certain type. More...
 
template<typename Type , typename... Args>
void emplace (Args &&... args)
 Replaces the contained object by creating a new instance directly. More...
 
meta_sequence_container as_sequence_container () ENTT_NOEXCEPT
 Returns a sequence container proxy. More...
 
meta_sequence_container as_sequence_container () const ENTT_NOEXCEPT
 Returns a sequence container proxy. More...
 
meta_associative_container as_associative_container () ENTT_NOEXCEPT
 Returns an associative container proxy. More...
 
meta_associative_container as_associative_container () const ENTT_NOEXCEPT
 Returns an associative container proxy. More...
 
meta_any operator* () ENTT_NOEXCEPT
 Indirection operator for dereferencing opaque objects. More...
 
meta_any operator* () const ENTT_NOEXCEPT
 Indirection operator for dereferencing opaque objects. More...
 
 operator bool () const ENTT_NOEXCEPT
 Returns false if a wrapper is invalid, true otherwise. More...
 
bool operator== (const meta_any &other) const
 Checks if two wrappers differ in their content. More...
 

Friends

void swap (meta_any &lhs, meta_any &rhs)
 Swaps two meta any objects. More...
 
meta_any as_ref (meta_any &other) ENTT_NOEXCEPT
 Aliasing constructor. More...
 
meta_any as_ref (const meta_any &other) ENTT_NOEXCEPT
 Aliasing constructor. More...
 

Detailed Description

Opaque wrapper for values of any type.

Constructor & Destructor Documentation

◆ meta_any() [1/5]

template<typename Type , typename... Args>
entt::meta_any::meta_any ( std::in_place_type_t< Type >  ,
Args &&...  args 
)
inlineexplicit

Constructs a meta any by directly initializing the new object.

Template Parameters
TypeType of object to use to initialize the wrapper.
ArgsTypes of arguments to use to construct the new instance.
Parameters
argsParameters to use to construct the instance.

◆ meta_any() [2/5]

template<typename Type >
entt::meta_any::meta_any ( std::reference_wrapper< Type >  value)
inline

Constructs a meta any that holds an unmanaged object.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueAn instance of an object to use to initialize the wrapper.

◆ meta_any() [3/5]

template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>>>
entt::meta_any::meta_any ( Type &&  value)
inline

Constructs a meta any from a given value.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueAn instance of an object to use to initialize the wrapper.

◆ meta_any() [4/5]

entt::meta_any::meta_any ( const meta_any other)
default

Copy constructor.

Parameters
otherThe instance to copy from.

◆ meta_any() [5/5]

entt::meta_any::meta_any ( meta_any &&  other)
inline

Move constructor.

Parameters
otherThe instance to move from.

Member Function Documentation

◆ allow_cast() [1/2]

template<typename Type >
meta_any entt::meta_any::allow_cast ( ) const
inline

Tries to make an instance castable to a certain type.

Template Parameters
TypeType to which the cast is requested.
Returns
A valid meta any object if there exists a a viable conversion that makes the cast possible, an invalid object otherwise.

◆ allow_cast() [2/2]

template<typename Type >
bool entt::meta_any::allow_cast ( )
inline

Tries to make an instance castable to a certain type.

Template Parameters
TypeType to which the cast is requested.
Returns
True if there exists a a viable conversion that makes the cast possible, false otherwise.

◆ as_associative_container() [1/2]

meta_associative_container entt::meta_any::as_associative_container ( )
inline

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

◆ as_associative_container() [2/2]

meta_associative_container entt::meta_any::as_associative_container ( ) const
inline

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

◆ as_sequence_container() [1/2]

meta_sequence_container entt::meta_any::as_sequence_container ( )
inline

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

◆ as_sequence_container() [2/2]

meta_sequence_container entt::meta_any::as_sequence_container ( ) const
inline

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

◆ cast() [1/2]

template<typename Type >
Type entt::meta_any::cast ( ) const
inline

Tries to cast an instance to a given type.

The type of the instance must be such that the cast is possible.

Warning
Attempting to perform a cast that isn't viable results in undefined behavior.
Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

◆ cast() [2/2]

template<typename Type >
Type entt::meta_any::cast ( )
inline

Tries to cast an instance to a given type.

The type of the instance must be such that the cast is possible.

Warning
Attempting to perform a cast that isn't viable results in undefined behavior.
Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

◆ data() [1/2]

const void* entt::meta_any::data ( ) const
inline

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

◆ data() [2/2]

void* entt::meta_any::data ( )
inline

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

◆ emplace()

template<typename Type , typename... Args>
void entt::meta_any::emplace ( Args &&...  args)
inline

Replaces the contained object by creating a new instance directly.

Template Parameters
TypeType of object to use to initialize the wrapper.
ArgsTypes of arguments to use to construct the new instance.
Parameters
argsParameters to use to construct the instance.

◆ get() [1/2]

meta_any entt::meta_any::get ( const id_type  id) const
inline

Gets the value of a given variable.

Parameters
idUnique identifier.
Returns
A meta any containing the value of the underlying variable.

◆ get() [2/2]

meta_any entt::meta_any::get ( const id_type  id)
inline

Gets the value of a given variable.

Parameters
idUnique identifier.
Returns
A meta any containing the value of the underlying variable.

◆ invoke() [1/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( const id_type  id,
Args &&...  args 
) const

Invokes the underlying function, if possible.

See also
invoke
Template Parameters
ArgsTypes of arguments to use to invoke the function.
Parameters
idUnique identifier.
argsParameters to use to invoke the function.
Returns
A meta any containing the returned value, if any.

◆ invoke() [2/2]

template<typename... Args>
meta_any entt::meta_any::invoke ( const id_type  id,
Args &&...  args 
)

Invokes the underlying function, if possible.

See also
invoke
Template Parameters
ArgsTypes of arguments to use to invoke the function.
Parameters
idUnique identifier.
argsParameters to use to invoke the function.
Returns
A meta any containing the returned value, if any.

◆ operator bool()

entt::meta_any::operator bool ( ) const
inlineexplicit

Returns false if a wrapper is invalid, true otherwise.

Returns
False if the wrapper is invalid, true otherwise.

◆ operator*() [1/2]

meta_any entt::meta_any::operator* ( )
inline

Indirection operator for dereferencing opaque objects.

Returns
A meta any that shares a reference to an unmanaged object if the wrapped element is dereferenceable, an invalid meta any otherwise.

◆ operator*() [2/2]

meta_any entt::meta_any::operator* ( ) const
inline

Indirection operator for dereferencing opaque objects.

Returns
A meta any that shares a reference to an unmanaged object if the wrapped element is dereferenceable, an invalid meta any otherwise.

◆ operator=()

meta_any& entt::meta_any::operator= ( meta_any  other)
inline

Assignment operator.

Parameters
otherThe instance to assign from.
Returns
This meta any object.

◆ operator==()

bool entt::meta_any::operator== ( const meta_any other) const
inline

Checks if two wrappers differ in their content.

Parameters
otherWrapper with which to compare.
Returns
False if the two objects differ in their content, true otherwise.

◆ set()

template<typename Type >
bool entt::meta_any::set ( const id_type  id,
Type &&  value 
)

Sets the value of a given variable.

The type of the value must be such that a cast or conversion to the type of the variable is possible. Otherwise, invoking the setter does nothing.

Template Parameters
TypeType of value to assign.
Parameters
idUnique identifier.
valueParameter to use to set the underlying variable.
Returns
True in case of success, false otherwise.

◆ try_cast() [1/2]

template<typename Type >
const Type* entt::meta_any::try_cast ( ) const
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A (possibly null) pointer to the contained instance.

◆ try_cast() [2/2]

template<typename Type >
Type* entt::meta_any::try_cast ( )
inline

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A (possibly null) pointer to the contained instance.

◆ type()

meta_type entt::meta_any::type ( ) const
inline

Returns the meta type of the underlying object.

Returns
The meta type of the underlying object, if any.

Friends And Related Function Documentation

◆ as_ref [1/2]

meta_any as_ref ( meta_any other)
friend

Aliasing constructor.

Parameters
otherA reference to an object that isn't necessarily initialized.
Returns
A meta any that shares a reference to an unmanaged object.

◆ as_ref [2/2]

meta_any as_ref ( const meta_any other)
friend

Aliasing constructor.

Parameters
otherA reference to an object that isn't necessarily initialized.
Returns
A meta any that shares a reference to an unmanaged object.

◆ swap

void swap ( meta_any lhs,
meta_any rhs 
)
friend

Swaps two meta any objects.

Parameters
lhsA valid meta any object.
rhsA valid meta any object.

The documentation for this class was generated from the following file: