any_regular_t Class ReferenceA runtime polymorphic type similar to boost::any which can hold any type which models Regular.
More...
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 | |
| any_regular_t (move_from< any_regular_t > x) | |
| any_regular_t (const any_regular_t &x) | |
| any_regular_t () | |
| any_regular_t & | operator= (any_regular_t x) |
| ~any_regular_t () | |
| any_regular_t & | assign (any_regular_t x) |
| template<typename T > | |
| any_regular_t & | assign (T x, typename move_sink< T >::type=0) |
| template<typename T > | |
| any_regular_t & | assign (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_tleveragesadobe::promotewhile 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_tusescast<>()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_tusesassign<>()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::anyin several ways:- any_regular_t models EqualityComparable, fully modeling a Regular.
- any_regular_t supports type promotion. See
adobe::promotefor more details. - cast<>() results are returned by reference, making any_regular_t generally more efficient.
- small values (less than or equal to 64 bits) with a non-throwing copy constructor or which model Movable are stored without a free store allocation.
- Note:
- With currently compilers the trait
boost::has_no_throw_copymust 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.
| any_regular_t | ( | move_from< any_regular_t > | x | ) |
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>::typeand stored in the object.
Definition at line 528 of file any_regular.hpp.
| any_regular_t | ( | T | x, | |
| typename move_sink< T >::type | = 0 | |||
| ) | [explicit] |
- Parameters:
-
x Value is promoted to type promote<T>::typeand stored in the object.
Definition at line 532 of file any_regular.hpp.
Member Function Documentation
| any_regular_t& assign | ( | any_regular_t | x | ) |
- 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 | ( | T | 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
Tis equal topromote<T>::typeotherwisestatic_cast<T>(value)where value is the stored value is return.
- Exceptions:
-
adobe::bad_cast Thrown if promote<T>::typedoes not match the store instance type.
- Returns:
- A refernce to a promoted type for
Tcontaining theany_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
Tcontaining theany_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>::typeis equal toTthen the value stored will be assigned tox, otherwisexis unchanged
- Returns:
trueifxwas assigned to,falseotherwise.
- Parameters:
-
x Value that will be set to the value stored in the any_regular_t.
- Returns:
trueif x was set successfully,falseotherwise.
- 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:
trueifxcontainsempty_t(),falseotherwise.
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] |

