An Any class represents a general type and is capable of storing any type. More...

#include <mn_any.hpp>

+ Collaboration diagram for mn::container::basic_any:

Classes

class  basic_any_holder
 Interface class for the holder. More...
 
class  basic_any_holder_impl
 The real impl of the basic_any holder. More...
 

Public Types

using self_type = basic_any< TAllocator >
 
using holder_type = basic_any_holder
 

Public Member Functions

constexpr basic_any () noexcept
 Construct an empty basic_any type. More...
 
template<class T >
 basic_any (const T &other)
 Construct an any which stores the init parameter inside. More...
 
 basic_any (const self_type &other)
 Copy constructor, works with both empty and initialized Any values. More...
 
 basic_any (self_type &&other) noexcept
 Copy constructor, works with both empty and initialized Any values. More...
 
 ~basic_any ()
 Deconstructor of this basic_any object. More...
 
void reset () noexcept
 Reset the basic_any. More...
 
self_typeswap (any &other) noexcept
 Swaps the content of the two Anys. More...
 
bool has_value () const noexcept
 Has the basic_any any value? More...
 
bool is_empty () const noexcept
 if the basic_any empty? More...
 
const std::type_info & type () const noexcept
 Returns the type information of the stored content. More...
 
template<class T >
const T * to_pointer () const
 Get the content as pointer. More...
 
template<class T >
T * to_pointer ()
 Get the content as pointer. More...
 
self_typeoperator= (const self_type &other) noexcept
 Assignment operator for basic_any. More...
 
self_typeoperator= (self_type &&other) noexcept
 Assignment operator for basic_any. More...
 
template<typename T >
self_typeoperator= (const T &other) noexcept
 Assignment operator for all types. More...
 
template<class T , class... Args>
void emplace (Args &&... args)
 emplace More...
 

Private Member Functions

void construct (const self_type &other)
 Helper function to construct the basic_any from other basic_any. More...
 
template<class T >
void construct (const T &other)
 Helper function to construct the basic_any from value. More...
 
void deconstruct (bool bdelete=false)
 Helper function to deconstruct. More...
 

Private Attributes

holder_type m_asyContent
 Holder of the value. More...
 

Detailed Description

An Any class represents a general type and is capable of storing any type.

Note
Code taken from https://github.com/martinmoene/any-lite. Original copyright by Martin Moene. Distributed under the Boost Software License, Version 1.0.
Modified for MiniThread

Member Typedef Documentation

◆ holder_type

◆ self_type

Constructor & Destructor Documentation

◆ basic_any() [1/4]

constexpr mn::container::basic_any::basic_any ( )
inlineconstexprnoexcept

Construct an empty basic_any type.

◆ basic_any() [2/4]

template<class T >
mn::container::basic_any::basic_any ( const T &  other)
inline

Construct an any which stores the init parameter inside.

◆ basic_any() [3/4]

mn::container::basic_any::basic_any ( const self_type other)
inline

Copy constructor, works with both empty and initialized Any values.

◆ basic_any() [4/4]

mn::container::basic_any::basic_any ( self_type &&  other)
inlinenoexcept

Copy constructor, works with both empty and initialized Any values.

◆ ~basic_any()

mn::container::basic_any::~basic_any ( )
inline

Deconstructor of this basic_any object.

Member Function Documentation

◆ construct() [1/2]

void mn::container::basic_any::construct ( const self_type other)
inlineprivate

Helper function to construct the basic_any from other basic_any.

◆ construct() [2/2]

template<class T >
void mn::container::basic_any::construct ( const T &  other)
inlineprivate

Helper function to construct the basic_any from value.

◆ deconstruct()

void mn::container::basic_any::deconstruct ( bool  bdelete = false)
inlineprivate

Helper function to deconstruct.

Parameters
bdeleteThen free the content.
Note
only call with true in deconstructor.

◆ emplace()

template<class T , class... Args>
void mn::container::basic_any::emplace ( Args &&...  args)
inline

emplace

◆ has_value()

bool mn::container::basic_any::has_value ( ) const
inlinenoexcept

Has the basic_any any value?

Returns
True The basic_any is has any value and if false then not.

◆ is_empty()

bool mn::container::basic_any::is_empty ( ) const
inlinenoexcept

if the basic_any empty?

Returns
True The basic_any is empty and if false then not.

◆ operator=() [1/3]

self_type& mn::container::basic_any::operator= ( const self_type other)
inlinenoexcept

Assignment operator for basic_any.

◆ operator=() [2/3]

template<typename T >
self_type& mn::container::basic_any::operator= ( const T &  other)
inlinenoexcept

Assignment operator for all types.

◆ operator=() [3/3]

self_type& mn::container::basic_any::operator= ( self_type &&  other)
inlinenoexcept

Assignment operator for basic_any.

◆ reset()

void mn::container::basic_any::reset ( )
inlinenoexcept

Reset the basic_any.

◆ swap()

self_type& mn::container::basic_any::swap ( any &  other)
inlinenoexcept

Swaps the content of the two Anys.

◆ to_pointer() [1/2]

template<class T >
T* mn::container::basic_any::to_pointer ( )
inline

Get the content as pointer.

Returns
The content as pointer.

◆ to_pointer() [2/2]

template<class T >
const T* mn::container::basic_any::to_pointer ( ) const
inline

Get the content as pointer.

Returns
The content as pointer.

◆ type()

const std::type_info& mn::container::basic_any::type ( ) const
inlinenoexcept

Returns the type information of the stored content.

Returns
the type information of the stored content or when empty then the typeid from void.

Member Data Documentation

◆ m_asyContent

holder_type mn::container::basic_any::m_asyContent
private

Holder of the value.


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