EnTT 3.14.0
Loading...
Searching...
No Matches
entt::basic_any< Len, size_t > Class Template Reference

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

#include <any.hpp>

Collaboration diagram for entt::basic_any< Len, size_t >:

Public Member Functions

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

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 = sizeof(double[2]), std::size_t = alignof(double[2])>
class entt::basic_any< Len, size_t >

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 11 of file fwd.hpp.

Constructor & Destructor Documentation

◆ basic_any() [1/5]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
entt::basic_any< Len, size_t >::basic_any ( )
inlineconstexprnoexcept

Default constructor.

Definition at line 164 of file any.hpp.

◆ basic_any() [2/5]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<typename Type , typename... Args>
entt::basic_any< Len, size_t >::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 174 of file any.hpp.

◆ basic_any() [3/5]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
entt::basic_any< Len, size_t >::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 188 of file any.hpp.

◆ basic_any() [4/5]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
entt::basic_any< Len, size_t >::basic_any ( const basic_any< Len, size_t > & other)
inline

Copy constructor.

Parameters
otherThe instance to copy from.

Definition at line 195 of file any.hpp.

◆ basic_any() [5/5]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
entt::basic_any< Len, size_t >::basic_any ( basic_any< Len, size_t > && other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 206 of file any.hpp.

◆ ~basic_any()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
entt::basic_any< Len, size_t >::~basic_any ( )
inline

Frees the internal storage, whatever it means.

Definition at line 217 of file any.hpp.

Member Function Documentation

◆ as_ref() [1/2]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
basic_any entt::basic_any< Len, size_t >::as_ref ( ) const
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 404 of file any.hpp.

◆ as_ref() [2/2]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
basic_any entt::basic_any< Len, size_t >::as_ref ( )
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 399 of file any.hpp.

◆ assign() [1/2]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
bool entt::basic_any< Len, size_t >::assign ( basic_any< Len, size_t > && 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 340 of file any.hpp.

◆ assign() [2/2]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
bool entt::basic_any< Len, size_t >::assign ( const basic_any< Len, size_t > & 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 331 of file any.hpp.

◆ data() [1/4]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
const void * entt::basic_any< Len, size_t >::data ( ) const
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 284 of file any.hpp.

◆ data() [2/4]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
void * entt::basic_any< Len, size_t >::data ( )
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 301 of file any.hpp.

◆ data() [3/4]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
const void * entt::basic_any< Len, size_t >::data ( const type_info & req) const
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

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

Definition at line 293 of file any.hpp.

◆ data() [4/4]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
void * entt::basic_any< Len, size_t >::data ( const type_info & req)
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

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

Definition at line 310 of file any.hpp.

◆ emplace()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<typename Type , typename... Args>
void entt::basic_any< Len, size_t >::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 321 of file any.hpp.

◆ operator bool()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
entt::basic_any< Len, size_t >::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 369 of file any.hpp.

◆ operator!=()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
bool entt::basic_any< Len, size_t >::operator!= ( const basic_any< Len, size_t > & 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 391 of file any.hpp.

◆ operator=() [1/3]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
basic_any & entt::basic_any< Len, size_t >::operator= ( basic_any< Len, size_t > && other)
inlinenoexcept

Move assignment operator.

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

Definition at line 245 of file any.hpp.

◆ operator=() [2/3]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
basic_any & entt::basic_any< Len, size_t >::operator= ( const basic_any< Len, size_t > & other)
inline

Copy assignment operator.

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

Definition at line 228 of file any.hpp.

◆ operator=() [3/3]

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Type>, basic_any>>>
basic_any & entt::basic_any< Len, size_t >::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 267 of file any.hpp.

◆ operator==()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
bool entt::basic_any< Len, size_t >::operator== ( const basic_any< Len, size_t > & 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 378 of file any.hpp.

◆ policy()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
any_policy entt::basic_any< Len, size_t >::policy ( ) const
inlinenodiscardnoexcept

Returns the current mode of an any object.

Returns
The current mode of the any object.

Definition at line 412 of file any.hpp.

◆ reset()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
void entt::basic_any< Len, size_t >::reset ( )
inline

Destroys contained object.

Definition at line 353 of file any.hpp.

◆ type()

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
const type_info & entt::basic_any< Len, size_t >::type ( ) const
inlinenodiscardnoexcept

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

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

Definition at line 276 of file any.hpp.

Member Data Documentation

◆ alignment

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
auto entt::basic_any< Len, size_t >::alignment = Align
staticconstexpr

Alignment requirement.

Definition at line 161 of file any.hpp.

◆ instance

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
const void* entt::basic_any< Len, size_t >::instance

Definition at line 418 of file any.hpp.

◆ length

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
auto entt::basic_any< Len, size_t >::length = Len
staticconstexpr

Size of the internal storage.

Definition at line 159 of file any.hpp.

◆ storage

template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
storage_type entt::basic_any< Len, size_t >::storage

Definition at line 419 of file any.hpp.


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