modm API documentation
modm::inplace_any< Size > Class Template Referencefinal

#include <modm/utils/inplace_any.hpp>

Public Member Functions

 inplace_any () noexcept = default
 Construct empty inplace_any.
 
 inplace_any (const inplace_any &other)
 
 inplace_any (inplace_any &&other) noexcept
 
inplace_any & operator= (const inplace_any &other)
 
inplace_any & operator= (inplace_any &&other) noexcept
 
template<size_t OtherSize>
 inplace_any (const inplace_any< OtherSize > &other)
 
template<size_t OtherSize>
 inplace_any (inplace_any< OtherSize > &&other) noexcept
 
template<size_t OtherSize>
inplace_any & operator= (const inplace_any< OtherSize > &other)
 
template<size_t OtherSize>
inplace_any & operator= (inplace_any< OtherSize > &&other) noexcept
 
template<typename T , typename... Args>
requires inplace_any_impl::compatible_value_type< T > inplace_any (std::in_place_type_t< T >, Args &&...args)
 In-place construct object.
 
template<typename T >
requires inplace_any_impl::compatible_value_type< T > inplace_any (T &&value)
 Initialize from object.
 
template<typename T >
requires inplace_any_impl::compatible_value_type< T > inplace_any & operator= (T &&value)
 Assign from object.
 
template<typename T , typename... Args>
requires inplace_any_impl::compatible_value_type< T > T & emplace (Args &&...args)
 Change the contained object, constructing the new object directly.
 
void reset () noexcept
 Destroy the contained object.
 
bool has_value () const noexcept
 Test if object has a value.
 
bool empty () const noexcept
 Test if object is empty.
 
 operator bool () const noexcept
 Test if object has a value.
 
void swap (inplace_any &other) noexcept
 

Friends

template<typename T , std::size_t S>
auto any_cast (const inplace_any< S > *any) noexcept-> std::add_pointer_t< std::add_const_t< std::remove_cvref_t< T >>>
 
template<typename T , std::size_t S>
auto any_cast (inplace_any< S > *any) noexcept-> std::add_pointer_t< std::remove_cvref_t< T >>
 
template<typename T , std::size_t S>
auto any_cast (const inplace_any< S > &any) noexcept-> std::add_const_t< std::remove_cvref_t< T >> &
 
template<typename T , std::size_t S>
auto any_cast (inplace_any< S > &any) noexcept-> std::remove_cvref_t< T > &
 

Detailed Description

template<std::size_t Size = 16>
class modm::inplace_any< Size >

Type-safe container for single values of any copy constructible type of size less than the capacity. The objects are stored in place, no allocation takes place.

All stored objects must by copy-constructible and nothrow move-constructible.

Warning
As this class is optimized for use without exceptions it only provides the basic exception safety guarantee for copy-assignment operations. Contrary to std::any, if copy-assignment throws a currently held value will be discarded.
Author
Christopher Durand

Constructor & Destructor Documentation

template<std::size_t Size = 16>
template<size_t OtherSize>
modm::inplace_any< Size >::inplace_any ( const inplace_any< OtherSize > &  other)

Copy-construct from inplace_any with smaller capacity

Precondition
OtherSize <= Size
template<std::size_t Size = 16>
template<size_t OtherSize>
modm::inplace_any< Size >::inplace_any ( inplace_any< OtherSize > &&  other)
noexcept

Move-construct from inplace_any with smaller capacity

Precondition
OtherSize <= Size

Member Function Documentation

template<std::size_t Size = 16>
template<size_t OtherSize>
inplace_any& modm::inplace_any< Size >::operator= ( const inplace_any< OtherSize > &  other)

Copy-assign from inplace_any with smaller capacity

Precondition
OtherSize <= Size
template<std::size_t Size = 16>
template<size_t OtherSize>
inplace_any& modm::inplace_any< Size >::operator= ( inplace_any< OtherSize > &&  other)
noexcept

Move-assign from inplace_any with smaller capacity

Precondition
OtherSize <= Size

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