A runtime polymorphic type similar to boost::any which can hold any type which models Regular.
More...
#include <any_regular.hpp>
- 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.
◆ any_regular_t() [1/4]
◆ any_regular_t() [2/4]
◆ any_regular_t() [3/4]
◆ ~any_regular_t()
◆ any_regular_t() [4/4]
- Parameters
-
x | Value 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.
◆ operator=()
◆ cast() [1/3]
- 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.
Definition at line 445 of file any_regular.hpp.
◆ cast() [2/3]
template<typename T>
traits< T >::const_result_type cast |
( |
| ) |
const |
◆ 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
-
- Returns
- A refernce to a promoted type for
T
containing the any_regular_t
's instance value.
- Exceptions
-
Definition at line 467 of file any_regular.hpp.
◆ assign() [1/2]
◆ assign() [2/2]
◆ 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
◆ adobe::runtime_cast_t
template<typename, typename>
◆ operator==
◆ swap
◆ empty()
- Returns
- true if
x
contains empty_t()
, false otherwise.
Definition at line 677 of file any_regular.hpp.