Standard library » Containers » Any module

std::any like container with the capacity defined at compile time.

It doesn't throw exceptions. Instead, asserts are used to ensure valid usage.

Files

file bn_any.h
file bn_any_fwd.h

Classes

class bn::iany
Base class of bn::any.
template<int MaxSize, int MaxAlignment = alignof(int)>
class bn::any
std::any like container with a fixed size buffer.

Functions

template<typename Type>
auto any_cast(const iany* any) -> const Type*
Performs type-safe access to the contained object of the given iany.
template<typename Type>
auto any_cast(iany* any) -> Type*
Performs type-safe access to the contained object of the given iany.
template<typename Type, typename... Args>
auto make_any(Args && ... args) -> any<sizeof(Type), alignof(Type)>
Creates an any deducing its size and alignment from the given Type.

Function documentation

#include <bn_any.h>
template<typename Type>
const Type* any_cast(const iany* any)

Performs type-safe access to the contained object of the given iany.

Template parameters
Type Type of the contained value.
Parameters
any Target iany object.
Returns If the given iany pointer is not null, and the type_id_t of the requested Type matches the type_id_t of the given iany, a const pointer to the value contained by operand; otherwise nullptr.

#include <bn_any.h>
template<typename Type>
Type* any_cast(iany* any)

Performs type-safe access to the contained object of the given iany.

Template parameters
Type Type of the contained value.
Parameters
any Target iany object.
Returns If the given iany pointer is not null, and the type_id_t of the requested Type matches the type_id_t of the given iany, a pointer to the value contained by operand; otherwise nullptr.

#include <bn_any.h>
template<typename Type, typename... Args>
any<sizeof(Type), alignof(Type)> make_any(Args && ... args)

Creates an any deducing its size and alignment from the given Type.

Template parameters
Type Type of the value to construct.
Args Types of the parameters of the value to construct.
Parameters
args Parameters of the value to construct.
Returns any containing to the constructed value.