Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
any_regular_t Class Reference

A runtime polymorphic type similar to boost::any which can hold any type which models Regular. More...

#include <any_regular.hpp>

Inheritance diagram for any_regular_t:

Classes

struct  helper< any_regular_t >
struct  transform
 Function object used in binding for instance value access. More...

Public Member Functions

Movable Functions
 any_regular_t ()
 any_regular_t (const any_regular_t &x)
 any_regular_t (any_regular_t &&x) noexcept
any_regular_toperator= (any_regular_t x)
 ~any_regular_t ()
template<typename T>
 any_regular_t (T x)
template<typename T>
bool cast (T &x) const
template<typename T>
traits< T >::const_result_type cast () const
template<typename T>
traits< T >::result_type cast ()
template<typename T>
any_regular_tassign (T x)
any_regular_tassign (any_regular_t x)
const std::type_info & type_info () const

Friends

template<typename T>
struct helper
template<typename, typename>
struct adobe::runtime_cast_t
bool operator== (const any_regular_t &x, const any_regular_t &y)
void swap (any_regular_t &x, any_regular_t &y)

(Note that these are not member symbols.)

bool empty (const any_regular_t &x)

Detailed Description

Model Of
Details
Type Promotion
any_regular_t leverages adobe::promote while storing instance values.
Todo
The reliance of any_regular_t on type promotion is current problematic and really ammounts to a poor-mans approach to refinements. In this case the desired functionality is to be able to extract something which models a number regardless of the actual numeric type stored. The feature becomes especially important if serialization happens between the writer and reader. This is still an open problem.
Getting a Value
any_regular_t uses cast<>() to get its instance value. It behaves like an explicit cast getting a any_regular_t out will always succeed and simply returns the same any_regular_t.
Setting a Value
any_regular_t uses assign<>() to set its instance value. It behaves like an explicit assignment. Assigning an any_regular_t into a any_regular_t simply assigns the values; it does not introduce another layer of indirection.
How does adobe::any_regular_t differ from boost::any?
any_regular_t differs from boost::any in several ways:
See Also
adobe::runtime_cast
Tutorial
A tutorial for any_regular_t is available.

Definition at line 356 of file any_regular.hpp.

Constructor & Destructor Documentation

◆ any_regular_t() [1/4]

Definition at line 402 of file any_regular.hpp.

◆ any_regular_t() [2/4]

Definition at line 404 of file any_regular.hpp.

◆ any_regular_t() [3/4]

any_regular_t ( any_regular_t && x)
noexcept

Definition at line 406 of file any_regular.hpp.

◆ ~any_regular_t()

Definition at line 414 of file any_regular.hpp.

◆ any_regular_t() [4/4]

template<typename T>
any_regular_t ( T x)
Parameters
xValue to copy as the instance value of this object.
Note
What is stored is a copy of x promoted to promote<T>::type.

Definition at line 427 of file any_regular.hpp.

Member Function Documentation

◆ operator=()

any_regular_t & operator= ( any_regular_t x)

Definition at line 408 of file any_regular.hpp.

◆ cast() [1/3]

template<typename T>
bool cast ( T & x) const
Parameters
xIf promote<T>::type is equal to T then the value stored will be assigned to x, otherwise x is unchanged
Returns
true if x was assigned to, false otherwise.

Definition at line 445 of file any_regular.hpp.

◆ cast() [2/3]

template<typename T>
traits< T >::const_result_type cast ( ) const
Returns
A refernce to a promoted type for T containing the any_regular_t's instance value.
Exceptions
adobe::bad_castThrown if adobe::promote<T> does not match the stored instance type.

Definition at line 453 of file any_regular.hpp.

◆ cast() [3/3]

template<typename T>
traits< T >::result_type cast ( )
Returns
A [const]referece to the stored value if T is equal to promote<T>::type otherwise static_cast<T>(value) where value is the stored value is return.
Exceptions
adobe::bad_castThrown if promote<T>::type does not match the store instance type.
Returns
A refernce to a promoted type for T containing the any_regular_t's instance value.
Exceptions
adobe::bad_castThrown if adobe::promote<T> does not match the stored instance type.

Definition at line 467 of file any_regular.hpp.

◆ assign() [1/2]

template<typename T>
any_regular_t & assign ( T x)
Parameters
xAssigned to the stored value.
Returns
The any_regular_t with its new value.

Definition at line 485 of file any_regular.hpp.

◆ assign() [2/2]

Definition at line 491 of file any_regular.hpp.

◆ type_info()

const std::type_info & type_info ( ) const
Returns
The information returned by adobe::type_info<T>() for the stored value.
The information returned by typeid() for the instance value.

Definition at line 506 of file any_regular.hpp.

◆ helper

template<typename T>
friend struct helper
friend

Definition at line 391 of file any_regular.hpp.

◆ adobe::runtime_cast_t

template<typename, typename>
friend struct adobe::runtime_cast_t
friend

Definition at line 567 of file any_regular.hpp.

◆ operator==

bool operator== ( const any_regular_t & x,
const any_regular_t & y )
friend

Definition at line 582 of file any_regular.hpp.

◆ swap

void swap ( any_regular_t & x,
any_regular_t & y )
friend

Definition at line 586 of file any_regular.hpp.

◆ empty()

bool empty ( const any_regular_t & x)
related
Returns
true if x contains empty_t(), false otherwise.

Definition at line 677 of file any_regular.hpp.