13.1.25.5 Widening to Object
Sometimes it is desirable to extract an object reference from an Any as the base Object type. This can be accomplished using a helper type similar to those required for extracting boolean, char, and octet:
// C++
class Any
{
public:
...
struct to_object {
to_object(Object_ptr &obj) : ref(obj) {}
Object_ptr &ref;
;
Boolean operator>>=(to_object) const;
...
};
The to_object
helper type is used to extract an
object reference from an Any as the base Object type. If the Any
contains a value of an object reference type as indicated by its
TypeCode, the extraction function
operator>>=(to_object)
explicitly widens its
contained object reference to Object and returns TRUE
;
otherwise, it returns FALSE. This is the only object reference
extraction function that performs widening on the extracted object
reference. As with regular object reference extraction, no
duplication of the object reference is performed by the
to_object
extraction operator.
Parent topic: Any Type