stlab.adobe.com Adobe Systems Incorporated

any_regular_t Class Reference
[any_regular_t]

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

#include <any_regular.hpp>

List of all members.

Classes

struct  transform
 Function object used in binding for instance value access. More...

Public Member Functions

Movable Functions
See:
Movable
 any_regular_t ()
 any_regular_t (const any_regular_t &x)
 any_regular_t (move_from< any_regular_t > x)
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)
type_info_t type_info () const

Friends

std::ostream & operator<< (std::ostream &out, const any_regular_t &value)
bool operator== (const any_regular_t &x, const any_regular_t &y)
void swap (any_regular_t &x, any_regular_t &y)

Related Functions

(Note that these are not member functions.)


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:
Note:
With currently compilers the trait boost::has_no_throw_copy must be manually declared for small types to be stored without a free store allocation.
See Also:
adobe::runtime_cast
Tutorial:
A tutorial for any_regular_t is available.

Definition at line 426 of file any_regular.hpp.


Constructor & Destructor Documentation

Definition at line 475 of file any_regular.hpp.

any_regular_t ( const any_regular_t x )

Definition at line 477 of file any_regular.hpp.

Definition at line 479 of file any_regular.hpp.

~any_regular_t (  )

Definition at line 488 of file any_regular.hpp.

any_regular_t ( x ) [explicit]
Parameters:
xValue is promoted to type promote<T>::type and stored in the object.

Definition at line 498 of file any_regular.hpp.


Member Function Documentation

any_regular_t& assign ( x )
Parameters:
xAssigned to the stored value.
Returns:
The any_regular_t with its new value.

Definition at line 553 of file any_regular.hpp.

Parameters:
xAssigned to the stored value.
Returns:
The any_regular_t with its new value.

Definition at line 560 of file any_regular.hpp.

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.
Parameters:
xValue that will be set to the value stored in the any_regular_t.
Returns:
true if x was set successfully, false otherwise.
Exceptions:
UndefinedWill relay anything thrown by x.operator=().

Definition at line 515 of file any_regular.hpp.

typename promote< T >::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 536 of file any_regular.hpp.

const typename promote< T >::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 523 of file any_regular.hpp.

any_regular_t& operator= ( any_regular_t  x )

Definition at line 481 of file any_regular.hpp.

type_info_t type_info (  ) const
Returns:
The information returned by adobe::type_info<T>() for the stored value.

Definition at line 576 of file any_regular.hpp.


Friends And Related Function Documentation

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

Definition at line 736 of file any_regular.hpp.

std::ostream& operator<< ( std::ostream &  out,
const any_regular_t value 
) [friend]
bool operator== ( const any_regular_t x,
const any_regular_t y 
) [friend]
void swap ( any_regular_t x,
any_regular_t y 
) [friend]

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google