Keyple Util C++ Library 2.3.0.5-SNAPSHOT
Reference Terminal Reader API for C++
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
keyple::core::util::cpp::any Class Referencefinal

#include <Any.h>

Public Member Functions

 any ()
 Constructs an object of type any with an empty state. More...
 
 any (const any &rhs)
 Constructs an object of type any with an equivalent state as other. More...
 
 any (any &&rhs) noexcept
 
 ~any ()
 Same effect as this->clear(). More...
 
template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
 any (ValueType &&value)
 
anyoperator= (const any &rhs)
 Has the same effect as any(rhs).swap(*this). No effects if an exception is thrown. More...
 
anyoperator= (any &&rhs) noexcept
 
template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
anyoperator= (ValueType &&value)
 
void clear () noexcept
 If not empty, destroys the contained object. More...
 
bool empty () const noexcept
 Returns true if *this has no contained object, otherwise false. More...
 
const std::type_info & type () const noexcept
 If *this has a contained object of type T, typeid(T); otherwise typeid(void). More...
 
void swap (any &rhs) noexcept
 Exchange the states of *this and rhs. More...
 

Protected Member Functions

bool is_typed (const std::type_info &t) const
 Same effect as is_same(this->type(), t);. More...
 
template<typename T >
const T * cast () const noexcept
 Casts (with no type_info checks) the storage pointer as const T*. More...
 
template<typename T >
T * cast () noexcept
 Casts (with no type_info checks) the storage pointer as T*. More...
 

Static Protected Member Functions

static bool is_same (const std::type_info &a, const std::type_info &b)
 

Friends

template<typename T >
const T * any_cast (const any *operand) noexcept
 
template<typename T >
T * any_cast (any *operand) noexcept
 

Detailed Description

Definition at line 58 of file Any.h.

Constructor & Destructor Documentation

◆ any() [1/4]

keyple::core::util::cpp::any::any ( )
inline

Constructs an object of type any with an empty state.

Definition at line 62 of file Any.h.

◆ any() [2/4]

keyple::core::util::cpp::any::any ( const any rhs)
inline

Constructs an object of type any with an equivalent state as other.

Definition at line 68 of file Any.h.

◆ any() [3/4]

keyple::core::util::cpp::any::any ( any &&  rhs)
inlinenoexcept

Constructs an object of type any with a state equivalent to the original state of other. rhs is left in a valid but otherwise unspecified state.

Definition at line 79 of file Any.h.

◆ ~any()

keyple::core::util::cpp::any::~any ( )
inline

Same effect as this->clear().

Definition at line 90 of file Any.h.

◆ any() [4/4]

template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
keyple::core::util::cpp::any::any ( ValueType &&  value)
inline

Constructs an object of type any that contains an object of type T direct-initialized with std::forward<ValueType>(value).

T shall satisfy the CopyConstructible requirements, otherwise the program is ill-formed. This is because an any may be copy constructed into another any at any time, so a copy should always be allowed.

Definition at line 100 of file Any.h.

Member Function Documentation

◆ cast() [1/2]

template<typename T >
const T * keyple::core::util::cpp::any::cast ( ) const
inlineprotectednoexcept

Casts (with no type_info checks) the storage pointer as const T*.

Definition at line 359 of file Any.h.

◆ cast() [2/2]

template<typename T >
T * keyple::core::util::cpp::any::cast ( )
inlineprotectednoexcept

Casts (with no type_info checks) the storage pointer as T*.

Definition at line 368 of file Any.h.

◆ clear()

void keyple::core::util::cpp::any::clear ( )
inlinenoexcept

If not empty, destroys the contained object.

Definition at line 138 of file Any.h.

◆ empty()

bool keyple::core::util::cpp::any::empty ( ) const
inlinenoexcept

Returns true if *this has no contained object, otherwise false.

Definition at line 148 of file Any.h.

◆ is_same()

static bool keyple::core::util::cpp::any::is_same ( const std::type_info &  a,
const std::type_info &  b 
)
inlinestaticprotected

Checks if two type infos are the same.

If ANY_IMPL_FAST_TYPE_INFO_COMPARE is defined, checks only the address of the type infos, otherwise does an actual comparision. Checking addresses is only a valid approach when there's no interaction with outside sources (other shared libraries and such).

Definition at line 347 of file Any.h.

◆ is_typed()

bool keyple::core::util::cpp::any::is_typed ( const std::type_info &  t) const
inlineprotected

Same effect as is_same(this->type(), t);.

Definition at line 334 of file Any.h.

◆ operator=() [1/3]

any & keyple::core::util::cpp::any::operator= ( any &&  rhs)
inlinenoexcept

Has the same effect as any(std::move(rhs)).swap(*this).

The state of *this is equivalent to the original state of rhs and rhs is left in a valid but otherwise unspecified state.

Definition at line 118 of file Any.h.

◆ operator=() [2/3]

any & keyple::core::util::cpp::any::operator= ( const any rhs)
inline

Has the same effect as any(rhs).swap(*this). No effects if an exception is thrown.

Definition at line 108 of file Any.h.

◆ operator=() [3/3]

template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
any & keyple::core::util::cpp::any::operator= ( ValueType &&  value)
inline

Has the same effect as any(std::forward<ValueType>(value)).swap(*this). No effect if a exception is thrown.

T shall satisfy the CopyConstructible requirements, otherwise the program is ill-formed. This is because an any may be copy constructed into another any at any time, so a copy should always be allowed.

Definition at line 129 of file Any.h.

◆ swap()

void keyple::core::util::cpp::any::swap ( any rhs)
inlinenoexcept

Exchange the states of *this and rhs.

Definition at line 162 of file Any.h.

◆ type()

const std::type_info & keyple::core::util::cpp::any::type ( ) const
inlinenoexcept

If *this has a contained object of type T, typeid(T); otherwise typeid(void).

Definition at line 155 of file Any.h.

Friends And Related Function Documentation

◆ any_cast [1/2]

template<typename T >
T * any_cast ( any operand)
friend

If operand != nullptr && operand->type() == typeid(ValueType), a pointer to the object contained by operand, otherwise nullptr.

Definition at line 484 of file Any.h.

◆ any_cast [2/2]

template<typename T >
const T * any_cast ( const any operand)
friend

If operand != nullptr && operand->type() == typeid(ValueType), a pointer to the object contained by operand, otherwise nullptr.

Definition at line 467 of file Any.h.


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