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

A SBO friendly, type-safe container for single values of any type. More...

#include <entt.hpp>

Public Member Functions

 any () ENTT_NOEXCEPT
 Default constructor.
 
template<typename Type , typename... Args>
 any (std::in_place_type_t< Type >, [[maybe_unused]] Args &&... args)
 Constructs an any by directly initializing the new object. More...
 
template<typename Type >
 any (std::reference_wrapper< Type > value) ENTT_NOEXCEPT
 Constructs an 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>>, any>>>
 any (Type &&value)
 Constructs an any from a given value. More...
 
 any (const any &other)
 Copy constructor. More...
 
 any (any &&other) ENTT_NOEXCEPT
 Move constructor. More...
 
 ~any ()
 Frees the internal storage, whatever it means.
 
anyoperator= (any other)
 Assignment operator. More...
 
type_info type () const ENTT_NOEXCEPT
 Returns the type of the contained 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 Type , typename... Args>
void emplace (Args &&... args)
 Replaces the contained object by creating a new instance directly. More...
 
 operator bool () const ENTT_NOEXCEPT
 Returns false if a wrapper is empty, true otherwise. More...
 
bool operator== (const any &other) const ENTT_NOEXCEPT
 Checks if two wrappers differ in their content. More...
 

Friends

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

Detailed Description

A SBO friendly, type-safe container for single values of any type.

Constructor & Destructor Documentation

◆ any() [1/5]

template<typename Type , typename... Args>
entt::any::any ( std::in_place_type_t< Type >  ,
[[maybe_unused] ] Args &&...  args 
)
inlineexplicit

Constructs an 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.

◆ any() [2/5]

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

Constructs an 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.

◆ any() [3/5]

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

Constructs an 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.

◆ any() [4/5]

entt::any::any ( const any other)
inline

Copy constructor.

Parameters
otherThe instance to copy from.

◆ any() [5/5]

entt::any::any ( any &&  other)
inline

Move constructor.

Parameters
otherThe instance to move from.

Member Function Documentation

◆ data() [1/2]

const void* entt::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::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::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.

◆ operator bool()

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

Returns false if a wrapper is empty, true otherwise.

Returns
False if the wrapper is empty, true otherwise.

◆ operator=()

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

Assignment operator.

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

◆ operator==()

bool entt::any::operator== ( const 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.

◆ type()

type_info entt::any::type ( ) const
inline

Returns the type of the contained object.

Returns
The type of the contained object, if any.

Friends And Related Function Documentation

◆ as_ref [1/2]

any as_ref ( any other)
friend

Aliasing constructor.

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

◆ as_ref [2/2]

any as_ref ( const any other)
friend

Aliasing constructor.

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

◆ swap

void swap ( any lhs,
any rhs 
)
friend

Swaps two any objects.

Parameters
lhsA valid any object.
rhsA valid any object.

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