EnTT 3.16.0
Loading...
Searching...
No Matches
entt::meta_any Class Reference

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

#include <meta.hpp>

Public Member Functions

 meta_any ()=default
 meta_any (meta_ctx_arg_t, const meta_ctx &area)
 Context aware constructor.
template<typename Type, typename... Args>
 meta_any (std::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object.
template<typename Type, typename... Args>
 meta_any (const meta_ctx &area, std::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object.
template<typename Type>
 meta_any (std::in_place_t, Type *value)
 Constructs a wrapper taking ownership of the passed object.
template<typename Type>
 meta_any (const meta_ctx &area, std::in_place_t, Type *value)
 Constructs a wrapper taking ownership of the passed object.
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
 meta_any (Type &&value)
 Constructs a wrapper from a given value.
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
 meta_any (const meta_ctx &area, Type &&value)
 Constructs a wrapper from a given value.
 meta_any (const meta_ctx &area, const meta_any &other)
 Context aware copy constructor.
 meta_any (const meta_ctx &area, meta_any &&other)
 Context aware move constructor.
 meta_any (const meta_any &other)=default
 Copy constructor.
 meta_any (meta_any &&other) noexcept
 Move constructor.
 ~meta_any ()=default
 Default destructor.
meta_any & operator= (const meta_any &other)
 Copy assignment operator.
meta_any & operator= (meta_any &&other) noexcept
 Move assignment operator.
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
meta_any & operator= (Type &&value)
 Value assignment operator.
meta_type type () const noexcept
 Returns the object type info if any, type_id<void>() otherwise.
template<typename... Args>
meta_any invoke (id_type id, Args &&...args) const
 Invokes the underlying function, if possible.
template<typename... Args>
meta_any invoke (id_type id, Args &&...args)
 Invokes the underlying function, if possible.
template<typename Type>
bool set (id_type id, Type &&value)
 Sets the value of a given variable.
meta_any get (id_type id) const
 Gets the value of a given variable.
meta_any get (id_type id)
 Gets the value of a given variable.
template<typename Type>
const Type * try_cast () const
 Tries to cast an instance to a given type.
template<typename Type>
Type * try_cast ()
 Tries to cast an instance to a given type.
template<typename Type>
std::remove_const_t< Type > cast () const
 Tries to cast an instance to a given type.
template<typename Type>
std::remove_const_t< Type > cast ()
 Tries to cast an instance to a given type.
meta_any allow_cast (const meta_type &type) const
 Converts an object in such a way that a given cast becomes viable.
bool allow_cast (const meta_type &type)
 Converts an object in such a way that a given cast becomes viable.
template<typename Type>
meta_any allow_cast () const
 Converts an object in such a way that a given cast becomes viable.
template<typename Type>
bool allow_cast ()
 Converts an object in such a way that a given cast becomes viable.
template<typename Type, typename... Args>
void emplace (Args &&...args)
 Replaces the contained object by creating a new instance directly.
bool assign (const meta_any &other)
 Assigns a value to the contained object without replacing it.
bool assign (meta_any &&other)
 Assigns a value to the contained object without replacing it.
void reset ()
 Destroys contained object.
meta_sequence_container as_sequence_container () noexcept
 Returns a sequence container proxy.
meta_sequence_container as_sequence_container () const noexcept
 Returns a sequence container proxy.
meta_associative_container as_associative_container () noexcept
 Returns an associative container proxy.
meta_associative_container as_associative_container () const noexcept
 Returns an associative container proxy.
meta_any operator* () const noexcept
 Indirection operator for dereferencing opaque objects.
 operator bool () const noexcept
 Returns false if a wrapper is empty, true otherwise.
bool operator== (const meta_any &other) const noexcept
 Checks if two wrappers differ in their content.
bool operator!= (const meta_any &other) const noexcept
 Checks if two wrappers differ in their content.
meta_any as_ref () noexcept
 Aliasing constructor.
meta_any as_ref () const noexcept
 Aliasing constructor.
const anybase () const noexcept
 Returns the underlying storage.
const meta_ctxcontext () const noexcept
 Returns the underlying meta context.

Detailed Description

Opaque wrapper for values of any type.

Definition at line 159 of file meta.hpp.

Constructor & Destructor Documentation

◆ meta_any() [1/12]

entt::meta_any::meta_any ( )
default

Default constructor.

◆ meta_any() [2/12]

entt::meta_any::meta_any ( meta_ctx_arg_t ,
const meta_ctx & area )
inline

Context aware constructor.

Parameters
areaThe context from which to search for meta types.

Definition at line 227 of file meta.hpp.

◆ meta_any() [3/12]

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

Constructs a wrapper 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.

Definition at line 237 of file meta.hpp.

◆ meta_any() [4/12]

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

Constructs a wrapper 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
areaThe context from which to search for meta types.
argsParameters to use to construct the instance.

Definition at line 248 of file meta.hpp.

◆ meta_any() [5/12]

template<typename Type>
entt::meta_any::meta_any ( std::in_place_t ,
Type * value )
inlineexplicit

Constructs a wrapper taking ownership of the passed object.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueA pointer to an object to take ownership of.

Definition at line 259 of file meta.hpp.

◆ meta_any() [6/12]

template<typename Type>
entt::meta_any::meta_any ( const meta_ctx & area,
std::in_place_t ,
Type * value )
inlineexplicit

Constructs a wrapper taking ownership of the passed object.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
areaThe context from which to search for meta types.
valueA pointer to an object to take ownership of.

Definition at line 269 of file meta.hpp.

◆ meta_any() [7/12]

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

Constructs a wrapper 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.

Definition at line 281 of file meta.hpp.

◆ meta_any() [8/12]

template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, meta_any>>>
entt::meta_any::meta_any ( const meta_ctx & area,
Type && value )
inline

Constructs a wrapper from a given value.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
areaThe context from which to search for meta types.
valueAn instance of an object to use to initialize the wrapper.

Definition at line 291 of file meta.hpp.

◆ meta_any() [9/12]

entt::meta_any::meta_any ( const meta_ctx & area,
const meta_any & other )
inline

Context aware copy constructor.

Parameters
areaThe context from which to search for meta types.
otherThe instance to copy from.

Definition at line 299 of file meta.hpp.

◆ meta_any() [10/12]

entt::meta_any::meta_any ( const meta_ctx & area,
meta_any && other )
inline

Context aware move constructor.

Parameters
areaThe context from which to search for meta types.
otherThe instance to move from.

Definition at line 310 of file meta.hpp.

◆ meta_any() [11/12]

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

Copy constructor.

Parameters
otherThe instance to copy from.

◆ meta_any() [12/12]

entt::meta_any::meta_any ( meta_any && other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 326 of file meta.hpp.

Member Function Documentation

◆ allow_cast() [1/4]

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

Converts an object in such a way that a given cast becomes viable.

Template Parameters
TypeType to which the cast is requested.
Returns
True if convertible, false otherwise.

Definition at line 507 of file meta.hpp.

◆ allow_cast() [2/4]

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

Converts an object in such a way that a given cast becomes viable.

Template Parameters
TypeType to which the cast is requested.
Returns
A valid meta object if convertible, an invalid one otherwise.

Definition at line 471 of file meta.hpp.

◆ allow_cast() [3/4]

bool entt::meta_any::allow_cast ( const meta_type & type)
inlinenodiscard

Converts an object in such a way that a given cast becomes viable.

Parameters
typeMeta type to which the cast is requested.
Returns
True if convertible, false otherwise.

Definition at line 1592 of file meta.hpp.

◆ allow_cast() [4/4]

meta_any entt::meta_any::allow_cast ( const meta_type & type) const
inlinenodiscard

Converts an object in such a way that a given cast becomes viable.

Parameters
typeMeta type to which the cast is requested.
Returns
A valid meta object if convertible, an invalid one otherwise.

Definition at line 1563 of file meta.hpp.

◆ as_associative_container() [1/2]

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

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 574 of file meta.hpp.

◆ as_associative_container() [2/2]

meta_associative_container entt::meta_any::as_associative_container ( )
inlinenodiscardnoexcept

Returns an associative container proxy.

Returns
An associative container proxy for the underlying object.

Definition at line 567 of file meta.hpp.

◆ as_ref() [1/2]

meta_any entt::meta_any::as_ref ( ) const
inlinenodiscardnoexcept

Aliasing constructor.

Returns
A wrapper that shares a reference to an unmanaged object.

Definition at line 612 of file meta.hpp.

◆ as_ref() [2/2]

meta_any entt::meta_any::as_ref ( )
inlinenodiscardnoexcept

Aliasing constructor.

Returns
A wrapper that shares a reference to an unmanaged object.

Definition at line 607 of file meta.hpp.

◆ as_sequence_container() [1/2]

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

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 557 of file meta.hpp.

◆ as_sequence_container() [2/2]

meta_sequence_container entt::meta_any::as_sequence_container ( )
inlinenodiscardnoexcept

Returns a sequence container proxy.

Returns
A sequence container proxy for the underlying object.

Definition at line 550 of file meta.hpp.

◆ assign() [1/2]

bool entt::meta_any::assign ( const meta_any & other)
inline

Assigns a value to the contained object without replacing it.

Parameters
otherThe value to assign to the contained object.
Returns
True in case of success, false otherwise.

Definition at line 1606 of file meta.hpp.

◆ assign() [2/2]

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

Assigns a value to the contained object without replacing it.

Parameters
otherThe value to assign to the contained object.
Returns
True in case of success, false otherwise.

Definition at line 1615 of file meta.hpp.

◆ base()

const any & entt::meta_any::base ( ) const
inlinenodiscardnoexcept

Returns the underlying storage.

Returns
The underlyig storage.

Definition at line 620 of file meta.hpp.

◆ cast() [1/2]

template<typename Type>
std::remove_const_t< Type > entt::meta_any::cast ( )
inlinenodiscard

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

Definition at line 444 of file meta.hpp.

◆ cast() [2/2]

template<typename Type>
std::remove_const_t< Type > entt::meta_any::cast ( ) const
inlinenodiscard

Tries to cast an instance to a given type.

Template Parameters
TypeType to which to cast the instance.
Returns
A reference to the contained instance.

Definition at line 436 of file meta.hpp.

◆ context()

const meta_ctx & entt::meta_any::context ( ) const
inlinenodiscardnoexcept

Returns the underlying meta context.

Returns
The underlying meta context.

Definition at line 628 of file meta.hpp.

◆ 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.

Definition at line 527 of file meta.hpp.

◆ get() [1/2]

meta_any entt::meta_any::get ( id_type id)
inlinenodiscard

Gets the value of a given variable.

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

Definition at line 1559 of file meta.hpp.

◆ get() [2/2]

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

Gets the value of a given variable.

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

Definition at line 1555 of file meta.hpp.

◆ invoke() [1/2]

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

Invokes the underlying function, if possible.

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

Definition at line 1546 of file meta.hpp.

◆ invoke() [2/2]

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

Invokes the underlying function, if possible.

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

Definition at line 1541 of file meta.hpp.

◆ operator bool()

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

Returns false if a wrapper is empty, true otherwise.

Returns
False if the wrapper is empty, true otherwise.

Definition at line 592 of file meta.hpp.

◆ operator!=()

bool entt::meta_any::operator!= ( const meta_any & other) const
inlinenodiscardnoexcept

Checks if two wrappers differ in their content.

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

Definition at line 602 of file meta.hpp.

◆ operator*()

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

Indirection operator for dereferencing opaque objects.

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

Definition at line 585 of file meta.hpp.

◆ operator=() [1/3]

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

Copy assignment operator.

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

Definition at line 340 of file meta.hpp.

◆ operator=() [2/3]

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

Move assignment operator.

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

Definition at line 356 of file meta.hpp.

◆ operator=() [3/3]

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

Value assignment operator.

Template Parameters
TypeType of object to use to initialize the wrapper.
Parameters
valueAn instance of an object to use to initialize the wrapper.
Returns
This meta any object.

Definition at line 371 of file meta.hpp.

◆ operator==()

bool entt::meta_any::operator== ( const meta_any & other) const
inlinenodiscardnoexcept

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.

Definition at line 597 of file meta.hpp.

◆ reset()

void entt::meta_any::reset ( )
inline

Destroys contained object.

Definition at line 540 of file meta.hpp.

◆ set()

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

Sets the value of a given variable.

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.

Definition at line 1551 of file meta.hpp.

◆ try_cast() [1/2]

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

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.

Definition at line 426 of file meta.hpp.

◆ try_cast() [2/2]

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

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.

Definition at line 419 of file meta.hpp.

◆ type()

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

Returns the object type info if any, type_id<void>() otherwise.

Returns
The object type info if any, type_id<void>() otherwise.

Definition at line 1535 of file meta.hpp.


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