EnTT  3.10.0
Public Member Functions | Static Public Attributes | List of all members
entt::basic_any< Len, Align > Class Template Reference

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

#include <any.hpp>

Public Member Functions

constexpr basic_any ()
 Default constructor.
 
template<typename Type , typename... Args>
 basic_any (std::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object. More...
 
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
 basic_any (Type &&value)
 Constructs a wrapper from a given value. More...
 
 basic_any (const basic_any &other)
 Copy constructor. More...
 
 basic_any (basic_any &&other)
 Move constructor. More...
 
 ~basic_any ()
 Frees the internal storage, whatever it means.
 
basic_any & operator= (const basic_any &other)
 Copy assignment operator. More...
 
basic_any & operator= (basic_any &&other)
 Move assignment operator. More...
 
template<typename Type >
std::enable_if_t<!std::is_same_v< std::decay_t< Type >, basic_any >, basic_any & > operator= (Type &&value)
 Value assignment operator. More...
 
const type_info & type () const
 Returns the object type if any, type_id<void>() otherwise. More...
 
const void * data () const
 Returns an opaque pointer to the contained instance. More...
 
const void * data (const type_info &req) const
 Returns an opaque pointer to the contained instance. More...
 
void * data ()
 Returns an opaque pointer to the contained instance. More...
 
void * data (const type_info &req)
 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...
 
bool assign (const any &other)
 Assigns a value to the contained object without replacing it. More...
 
bool assign (any &&other)
 Assigns a value to the contained object without replacing it. More...
 
void reset ()
 Destroys contained object.
 
 operator bool () const
 Returns false if a wrapper is empty, true otherwise. More...
 
bool operator== (const basic_any &other) const
 Checks if two wrappers differ in their content. More...
 
basic_any as_ref ()
 Aliasing constructor. More...
 
basic_any as_ref () const
 Aliasing constructor. More...
 
bool owner () const
 Returns true if a wrapper owns its object, false otherwise. More...
 

Static Public Attributes

static constexpr auto length = Len
 Size of the internal storage.
 
static constexpr auto alignment = Align
 Alignment requirement.
 

Detailed Description

template<std::size_t Len, std::size_t Align>
class entt::basic_any< Len, Align >

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

Template Parameters
LenSize of the storage reserved for the small buffer optimization.
AlignOptional alignment requirement.

Definition at line 22 of file any.hpp.

Constructor & Destructor Documentation

◆ basic_any() [1/4]

template<std::size_t Len, std::size_t Align>
template<typename Type , typename... Args>
entt::basic_any< Len, Align >::basic_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 156 of file any.hpp.

◆ basic_any() [2/4]

template<std::size_t Len, std::size_t Align>
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
entt::basic_any< Len, Align >::basic_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 167 of file any.hpp.

◆ basic_any() [3/4]

template<std::size_t Len, std::size_t Align>
entt::basic_any< Len, Align >::basic_any ( const basic_any< Len, Align > &  other)
inline

Copy constructor.

Parameters
otherThe instance to copy from.

Definition at line 176 of file any.hpp.

◆ basic_any() [4/4]

template<std::size_t Len, std::size_t Align>
entt::basic_any< Len, Align >::basic_any ( basic_any< Len, Align > &&  other)
inline

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 187 of file any.hpp.

Member Function Documentation

◆ as_ref() [1/2]

template<std::size_t Len, std::size_t Align>
basic_any entt::basic_any< Len, Align >::as_ref ( )
inline

Aliasing constructor.

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

Definition at line 366 of file any.hpp.

◆ as_ref() [2/2]

template<std::size_t Len, std::size_t Align>
basic_any entt::basic_any< Len, Align >::as_ref ( ) const
inline

Aliasing constructor.

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

Definition at line 371 of file any.hpp.

◆ assign() [1/2]

template<std::size_t Len, std::size_t Align>
bool entt::basic_any< Len, Align >::assign ( 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 318 of file any.hpp.

◆ assign() [2/2]

template<std::size_t Len, std::size_t Align>
bool entt::basic_any< Len, Align >::assign ( const 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 309 of file any.hpp.

◆ data() [1/4]

template<std::size_t Len, std::size_t Align>
void* entt::basic_any< Len, Align >::data ( )
inline

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 279 of file any.hpp.

◆ data() [2/4]

template<std::size_t Len, std::size_t Align>
const void* entt::basic_any< Len, Align >::data ( ) const
inline

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 262 of file any.hpp.

◆ data() [3/4]

template<std::size_t Len, std::size_t Align>
void* entt::basic_any< Len, Align >::data ( const type_info &  req)
inline

Returns an opaque pointer to the contained instance.

Parameters
reqExpected type.
Returns
An opaque pointer the contained instance, if any.

Definition at line 288 of file any.hpp.

◆ data() [4/4]

template<std::size_t Len, std::size_t Align>
const void* entt::basic_any< Len, Align >::data ( const type_info &  req) const
inline

Returns an opaque pointer to the contained instance.

Parameters
reqExpected type.
Returns
An opaque pointer the contained instance, if any.

Definition at line 271 of file any.hpp.

◆ emplace()

template<std::size_t Len, std::size_t Align>
template<typename Type , typename... Args>
void entt::basic_any< Len, Align >::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 299 of file any.hpp.

◆ operator bool()

template<std::size_t Len, std::size_t Align>
entt::basic_any< Len, Align >::operator bool ( ) const
inlineexplicit

Returns false if a wrapper is empty, true otherwise.

Returns
False if the wrapper is empty, true otherwise.

Definition at line 345 of file any.hpp.

◆ operator=() [1/3]

template<std::size_t Len, std::size_t Align>
basic_any& entt::basic_any< Len, Align >::operator= ( basic_any< Len, Align > &&  other)
inline

Move assignment operator.

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

Definition at line 224 of file any.hpp.

◆ operator=() [2/3]

template<std::size_t Len, std::size_t Align>
basic_any& entt::basic_any< Len, Align >::operator= ( const basic_any< Len, Align > &  other)
inline

Copy assignment operator.

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

Definition at line 209 of file any.hpp.

◆ operator=() [3/3]

template<std::size_t Len, std::size_t Align>
template<typename Type >
std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>, basic_any &> entt::basic_any< Len, Align >::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 any object.

Definition at line 245 of file any.hpp.

◆ operator==()

template<std::size_t Len, std::size_t Align>
bool entt::basic_any< Len, Align >::operator== ( const basic_any< Len, Align > &  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.

Definition at line 354 of file any.hpp.

◆ owner()

template<std::size_t Len, std::size_t Align>
bool entt::basic_any< Len, Align >::owner ( ) const
inline

Returns true if a wrapper owns its object, false otherwise.

Returns
True if the wrapper owns its object, false otherwise.

Definition at line 379 of file any.hpp.

◆ type()

template<std::size_t Len, std::size_t Align>
const type_info& entt::basic_any< Len, Align >::type ( ) const
inline

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

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

Definition at line 254 of file any.hpp.


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