Blender V4.3
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment > Class Template Reference

#include <BLI_any.hh>

Public Member Functions

 Any ()=default
 Any (const Any &other)
 Any (Any &&other) noexcept
template<typename T, typename... Args>
 Any (std::in_place_type_t< T >, Args &&...args)
template<typename T, BLI_ENABLE_IF((!is_same_any_v< T >))>
 Any (T &&value)
 ~Any ()
Anyoperator= (const Any &other)
template<typename T>
Anyoperator= (T &&other)
void reset ()
 operator bool () const
bool has_value () const
template<typename T, typename... Args>
std::decay_t< T > & emplace (Args &&...args)
template<typename T, typename... Args>
std::decay_t< T > & emplace_on_empty (Args &&...args)
template<typename T>
void * allocate ()
template<typename T>
void * allocate_on_empty ()
template<typename T>
bool is () const
void * get ()
const void * get () const
template<typename T>
Tget ()
template<typename T>
const Tget () const
const RealExtraInfo & extra_info () const

Static Public Attributes

template<typename T>
static constexpr bool is_allowed_v = std::is_copy_constructible_v<T>
template<typename T>
static constexpr bool is_inline_v
template<typename T>
static constexpr bool is_same_any_v = std::is_same_v<std::decay_t<T>, Any>

Detailed Description

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
class blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >
Template Parameters
ExtraInfoEither void or a struct that contains data members for additional type information. The struct has to have a static ExtraInfo get<T>() method that initializes the struct based on a type.
InlineBufferCapacitySize of the inline buffer. This allows types that are small enough to be stored directly inside the Any without an additional allocation.
AlignmentRequired minimum alignment of the inline buffer. If this is smaller than the alignment requirement of a used type, a separate allocation is necessary.

Definition at line 98 of file BLI_any.hh.

Constructor & Destructor Documentation

◆ Any() [1/5]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::Any ( )
default

◆ Any() [2/5]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::Any ( const Any< ExtraInfo, InlineBufferCapacity, Alignment > & other)
inline

Definition at line 155 of file BLI_any.hh.

◆ Any() [3/5]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::Any ( Any< ExtraInfo, InlineBufferCapacity, Alignment > && other)
inlinenoexcept
Note
The #other Any will not be empty afterwards if it was not before. Just its value is in a moved-from state.

Definition at line 173 of file BLI_any.hh.

◆ Any() [4/5]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T, typename... Args>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::Any ( std::in_place_type_t< T > ,
Args &&... args )
inlineexplicit

Constructs a new Any that contains the given type T from #args. The #std::in_place_type_t is used to disambiguate this and the copy/move constructors.

Definition at line 191 of file BLI_any.hh.

◆ Any() [5/5]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T, BLI_ENABLE_IF((!is_same_any_v< T >))>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::Any ( T && value)
inline

Constructs a new Any that contains the given value.

Definition at line 200 of file BLI_any.hh.

◆ ~Any()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::~Any ( )
inline

Member Function Documentation

◆ allocate()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
void * blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::allocate ( )
inline

Like emplace but does not actually construct the value. The caller is responsible for calling the constructor before the value is used.

Definition at line 291 of file BLI_any.hh.

Referenced by blender::tests::TEST().

◆ allocate_on_empty()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
void * blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::allocate_on_empty ( )
inline

Like emplace_on_empty but does not actually construct the value. The caller is responsible for calling the constructor before the value is used.

Definition at line 301 of file BLI_any.hh.

Referenced by blender::Any< detail::GVArrayAnyExtraInfo, 40, 8 >::allocate().

◆ emplace()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T, typename... Args>
std::decay_t< T > & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::emplace ( Args &&... args)
inline

Definition at line 260 of file BLI_any.hh.

◆ emplace_on_empty()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T, typename... Args>
std::decay_t< T > & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::emplace_on_empty ( Args &&... args)
inline

Definition at line 267 of file BLI_any.hh.

Referenced by blender::Any< detail::GVArrayAnyExtraInfo, 40, 8 >::Any().

◆ extra_info()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
const RealExtraInfo & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::extra_info ( ) const
inline

Get extra information that has been stored for the contained type.

Definition at line 375 of file BLI_any.hh.

◆ get() [1/4]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
void * blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::get ( )
inline

◆ get() [2/4]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
T & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::get ( )
inline

Get a reference to the stored value. This invokes undefined behavior when T does not have the correct type.

Definition at line 347 of file BLI_any.hh.

◆ get() [3/4]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
const void * blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::get ( ) const
inline

Get a pointer to the stored value.

Definition at line 334 of file BLI_any.hh.

◆ get() [4/4]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
const T & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::get ( ) const
inline

Get a reference to the stored value. This invokes undefined behavior when T does not have the correct type.

Definition at line 357 of file BLI_any.hh.

◆ has_value()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
bool blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::has_value ( ) const
inline

◆ is()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
bool blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::is ( ) const
inline

Return true when the value that is currently stored is a T.

Definition at line 318 of file BLI_any.hh.

Referenced by blender::tests::TEST(), and blender::tests::TEST().

◆ operator bool()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::operator bool ( ) const
inline

Definition at line 250 of file BLI_any.hh.

◆ operator=() [1/2]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
Any & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::operator= ( const Any< ExtraInfo, InlineBufferCapacity, Alignment > & other)
inline
Note
Only needed because the template below does not count as copy assignment operator.

Definition at line 216 of file BLI_any.hh.

◆ operator=() [2/2]

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
Any & blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::operator= ( T && other)
inline

Assign any value to the Any.

Definition at line 227 of file BLI_any.hh.

◆ reset()

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
void blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::reset ( )
inline

Destruct any existing value to make it empty.

Definition at line 240 of file BLI_any.hh.

Referenced by blender::Any< detail::GVArrayAnyExtraInfo, 40, 8 >::allocate(), and blender::tests::TEST().

Member Data Documentation

◆ is_allowed_v

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
bool blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::is_allowed_v = std::is_copy_constructible_v<T>
inlinestaticconstexpr

Only copy constructible types can be stored in Any.

Definition at line 121 of file BLI_any.hh.

◆ is_inline_v

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
bool blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::is_inline_v
inlinestaticconstexpr
Initial value:
= std::is_nothrow_move_constructible_v<T> &&
sizeof(T) <= InlineBufferCapacity &&
alignof(T) <= Alignment
#define T

Checks if the type will be stored in the inline buffer or if it requires a separate allocation.

Definition at line 128 of file BLI_any.hh.

◆ is_same_any_v

template<typename ExtraInfo = void, size_t InlineBufferCapacity = 8, size_t Alignment = 8>
template<typename T>
bool blender::Any< ExtraInfo, InlineBufferCapacity, Alignment >::is_same_any_v = std::is_same_v<std::decay_t<T>, Any>
inlinestaticconstexpr

Checks if T is the same type as this Any, because in this case the behavior of e.g. the assignment operator is different.

Definition at line 137 of file BLI_any.hh.


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