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.
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
Member Function Documentation
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 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:
-
- 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 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_cast | Thrown if adobe::promote<T> does not match the stored instance type. |
Definition at line 523 of file any_regular.hpp.
- 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
- 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] |