libnabo  1.0.6
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
linb::any Class Referencefinal

Public Member Functions

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

Protected Member Functions

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

Static Protected Member Functions

static bool is_same (const std::type_info &a, const std::type_info &b)
 Checks if two type infos are the same. More...
 

Friends

template<typename T >
const T * any_cast (const any *operand) noexcept
 If operand != nullptr && operand->type() == typeid(ValueType), a pointer to the object contained by operand, otherwise nullptr. More...
 
template<typename T >
T * any_cast (any *operand) noexcept
 If operand != nullptr && operand->type() == typeid(ValueType), a pointer to the object contained by operand, otherwise nullptr. More...
 

Constructor & Destructor Documentation

◆ any() [1/2]

linb::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.

◆ any() [2/2]

template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
linb::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.

Member Function Documentation

◆ is_same()

static bool linb::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).

◆ operator=() [1/2]

any& linb::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.

◆ operator=() [2/2]

template<typename ValueType , typename = typename std::enable_if<!std::is_same<typename std::decay<ValueType>::type, any>::value>::type>
any& linb::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.

Friends And Related Function Documentation

◆ any_cast [1/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.

◆ any_cast [2/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.


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