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

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

#include <any.hpp>

Inheritance diagram for entt::basic_any< Len, Align >:
Collaboration diagram for entt::basic_any< Len, Align >:

Public Member Functions

constexpr basic_any () noexcept
 Default constructor.
template<typename Type, typename... Args>
 basic_any (stl::in_place_type_t< Type >, Args &&...args)
 Constructs a wrapper by directly initializing the new object.
template<typename Type>
requires (!stl::is_const_v<Type> && !stl::is_void_v<Type>)
 basic_any (stl::in_place_t, Type *value)
 Constructs a wrapper taking ownership of the passed object.
template<typename Type>
requires (!stl::same_as<stl::remove_cvref_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 buffer, whatever it means.
basic_anyoperator= (const basic_any &other)
 Copy assignment operator.
basic_anyoperator= (basic_any &&other) noexcept
 Move assignment operator.
template<typename Type>
requires (!stl::same_as<stl::remove_cvref_t<Type>, basic_any>)
basic_anyoperator= (Type &&value)
 Value assignment operator.
bool has_value () const noexcept
 Returns false if a wrapper is empty, true otherwise.
bool has_value (const type_info &req) const noexcept
 Returns false if the wrapper does not contain the expected type, true otherwise.
template<cvref_unqualified Type>
bool has_value () const noexcept
 Returns false if the wrapper does not contain the expected type, true otherwise.
const type_infoinfo () const noexcept
 Returns the object type info 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.
template<typename Type>
const Type * data () 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>
Type * data () 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.
basic_any as_ref () noexcept
 Aliasing constructor.
basic_any as_ref () const noexcept
 Aliasing constructor.
bool owner () const noexcept
 Returns true if a wrapper owns its object, false otherwise.
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 buffer.
static constexpr auto alignment = Align
 Alignment requirement.

Detailed Description

template<stl::size_t Len, stl::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 buffer reserved for the small buffer optimization.
AlignOptional alignment requirement.

Definition at line 63 of file any.hpp.

Constructor & Destructor Documentation

◆ basic_any() [1/6]

template<stl::size_t Len, stl::size_t Align>
entt::basic_any< Len, Align >::basic_any ( )
inlineconstexprnoexcept

Default constructor.

Definition at line 189 of file any.hpp.

◆ basic_any() [2/6]

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

◆ basic_any() [3/6]

template<stl::size_t Len, stl::size_t Align>
template<typename Type>
requires (!stl::is_const_v<Type> && !stl::is_void_v<Type>)
entt::basic_any< Len, Align >::basic_any ( stl::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 211 of file any.hpp.

◆ basic_any() [4/6]

template<stl::size_t Len, stl::size_t Align>
template<typename Type>
requires (!stl::same_as<stl::remove_cvref_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 229 of file any.hpp.

◆ basic_any() [5/6]

template<stl::size_t Len, stl::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 236 of file any.hpp.

◆ basic_any() [6/6]

template<stl::size_t Len, stl::size_t Align>
entt::basic_any< Len, Align >::basic_any ( basic_any< Len, Align > && other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 245 of file any.hpp.

◆ ~basic_any()

template<stl::size_t Len, stl::size_t Align>
entt::basic_any< Len, Align >::~basic_any ( )
inline

Frees the internal buffer, whatever it means.

Definition at line 259 of file any.hpp.

Member Function Documentation

◆ as_ref() [1/2]

template<stl::size_t Len, stl::size_t Align>
basic_any entt::basic_any< Len, Align >::as_ref ( ) const
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 504 of file any.hpp.

◆ as_ref() [2/2]

template<stl::size_t Len, stl::size_t Align>
basic_any entt::basic_any< Len, Align >::as_ref ( )
inlinenodiscardnoexcept

Aliasing constructor.

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

Definition at line 486 of file any.hpp.

◆ assign() [1/2]

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

◆ assign() [2/2]

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

◆ data() [1/6]

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

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 362 of file any.hpp.

◆ data() [2/6]

template<stl::size_t Len, stl::size_t Align>
template<typename Type>
const Type * entt::basic_any< Len, Align >::data ( ) const
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

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

Definition at line 385 of file any.hpp.

◆ data() [3/6]

template<stl::size_t Len, stl::size_t Align>
void * entt::basic_any< Len, Align >::data ( )
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

Returns
An opaque pointer the contained instance, if any.

Definition at line 393 of file any.hpp.

◆ data() [4/6]

template<stl::size_t Len, stl::size_t Align>
template<typename Type>
Type * entt::basic_any< Len, Align >::data ( )
inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

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

Definition at line 412 of file any.hpp.

◆ data() [5/6]

template<stl::size_t Len, stl::size_t Align>
const void * entt::basic_any< Len, Align >::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 375 of file any.hpp.

◆ data() [6/6]

template<stl::size_t Len, stl::size_t Align>
void * entt::basic_any< Len, Align >::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 402 of file any.hpp.

◆ emplace()

template<stl::size_t Len, stl::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 427 of file any.hpp.

◆ has_value() [1/3]

template<stl::size_t Len, stl::size_t Align>
bool entt::basic_any< Len, Align >::has_value ( ) const
inlinenodiscardnoexcept

Returns false if a wrapper is empty, true otherwise.

Returns
False if the wrapper is empty, true otherwise.

Definition at line 323 of file any.hpp.

◆ has_value() [2/3]

template<stl::size_t Len, stl::size_t Align>
template<cvref_unqualified Type>
bool entt::basic_any< Len, Align >::has_value ( ) const
inlinenodiscardnoexcept

Returns false if the wrapper does not contain the expected type, true otherwise.

Template Parameters
TypeExpected type.
Returns
False if the wrapper does not contain the expected type, true otherwise.

Definition at line 346 of file any.hpp.

◆ has_value() [3/3]

template<stl::size_t Len, stl::size_t Align>
bool entt::basic_any< Len, Align >::has_value ( const type_info & req) const
inlinenodiscardnoexcept

Returns false if the wrapper does not contain the expected type, true otherwise.

Parameters
reqExpected type.
Returns
False if the wrapper does not contain the expected type, true otherwise.

Definition at line 334 of file any.hpp.

◆ info()

template<stl::size_t Len, stl::size_t Align>
const type_info & entt::basic_any< Len, Align >::info ( ) 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 354 of file any.hpp.

◆ operator bool()

template<stl::size_t Len, stl::size_t Align>
entt::basic_any< Len, Align >::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 465 of file any.hpp.

◆ operator=() [1/3]

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

Move assignment operator.

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

Definition at line 287 of file any.hpp.

◆ operator=() [2/3]

template<stl::size_t Len, stl::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 268 of file any.hpp.

◆ operator=() [3/3]

template<stl::size_t Len, stl::size_t Align>
template<typename Type>
requires (!stl::same_as<stl::remove_cvref_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 314 of file any.hpp.

◆ operator==()

template<stl::size_t Len, stl::size_t Align>
bool entt::basic_any< Len, Align >::operator== ( const basic_any< Len, Align > & 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 474 of file any.hpp.

◆ owner()

template<stl::size_t Len, stl::size_t Align>
bool entt::basic_any< Len, Align >::owner ( ) const
inlinenodiscardnoexcept

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

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

Definition at line 517 of file any.hpp.

◆ policy()

template<stl::size_t Len, stl::size_t Align>
any_policy entt::basic_any< Len, Align >::policy ( ) const
inlinenodiscardnoexcept

Returns the current mode of an any object.

Returns
The current mode of the any object.

Definition at line 525 of file any.hpp.

◆ reset()

template<stl::size_t Len, stl::size_t Align>
void entt::basic_any< Len, Align >::reset ( )
inline

Destroys contained object.

Definition at line 456 of file any.hpp.

Member Data Documentation

◆ alignment

template<stl::size_t Len, stl::size_t Align>
auto entt::basic_any< Len, Align >::alignment = Align
staticconstexpr

Alignment requirement.

Definition at line 186 of file any.hpp.

◆ length

template<stl::size_t Len, stl::size_t Align>
auto entt::basic_any< Len, Align >::length = Len
staticconstexpr

Size of the internal buffer.

Definition at line 184 of file any.hpp.


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