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

template<typename T >
 any_regular_t (T x, typename move_sink< T >::type=0)
template<typename T >
 any_regular_t (const T &x, typename copy_sink< T >::type=0)
Movable Functions
See:
Movable


 any_regular_t (move_from< any_regular_t > x)
 any_regular_t (const any_regular_t &x)
 any_regular_t ()
any_regular_toperator= (any_regular_t x)
 ~any_regular_t ()
any_regular_tassign (any_regular_t x)
template<typename T >
any_regular_tassign (T x, typename move_sink< T >::type=0)
template<typename T >
any_regular_tassign (const T &x, typename copy_sink< T >::type=0)
template<typename T >
traits< T >::result_type cast ()
template<typename T >
traits< T >::const_result_type cast () const
template<typename T >
bool cast (T &x) const
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 456 of file any_regular.hpp.


Constructor & Destructor Documentation

any_regular_t (  ) 

Definition at line 505 of file any_regular.hpp.

any_regular_t ( const any_regular_t x  ) 

Definition at line 507 of file any_regular.hpp.

Definition at line 509 of file any_regular.hpp.

~any_regular_t (  ) 

Definition at line 518 of file any_regular.hpp.

any_regular_t ( const T &  x,
typename copy_sink< T >::type  = 0 
) [explicit]

Parameters:
x Value is promoted to type promote<T>::type and stored in the object.

Definition at line 528 of file any_regular.hpp.

any_regular_t ( x,
typename move_sink< T >::type  = 0 
) [explicit]

Parameters:
x Value is promoted to type promote<T>::type and stored in the object.

Definition at line 532 of file any_regular.hpp.


Member Function Documentation

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

Definition at line 598 of file any_regular.hpp.

any_regular_t& assign ( x,
typename move_sink< T >::type  = 0 
)

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

Definition at line 591 of file any_regular.hpp.

any_regular_t& assign ( const T &  x,
typename copy_sink< T >::type  = 0 
)

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

Definition at line 587 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_cast Thrown 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_cast Thrown if adobe::promote<T> does not match the stored instance type.

Definition at line 570 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_cast Thrown if adobe::promote<T> does not match the stored instance type.

Definition at line 557 of file any_regular.hpp.

bool cast ( T &  x  )  const

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

Definition at line 549 of file any_regular.hpp.

any_regular_t& operator= ( any_regular_t  x  ) 

Definition at line 511 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 614 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 774 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