|  | Home | Libraries | People | FAQ | More | 
boost::polymorphic_relaxed_get — Retrieves a value of a specified type from a given
          variant.Unlike polymorphic_strict_get does not assert at compile time
        that type U is one of the types that can be stored in variant.
// In header: <boost/variant/polymorphic_get.hpp> template<typename U, typename T1, typename T2, ..., typename TN> U * polymorphic_relaxed_get(variant<T1, T2, ..., TN> * operand); template<typename U, typename T1, typename T2, ..., typename TN> const U * polymorphic_relaxed_get(const variant<T1, T2, ..., TN> * operand); template<typename U, typename T1, typename T2, ..., typename TN> U & polymorphic_relaxed_get(variant<T1, T2, ..., TN> & operand); template<typename U, typename T1, typename T2, ..., typename TN> const U & polymorphic_relaxed_get(const variant<T1, T2, ..., TN> & operand);
The polymorphic_get function allows run-time checked,
          type-safe retrieval of the content of the given
          variant. The function succeeds
          only if the content is of the specified type U or of type
          derived from type U, with
          failure indicated as described below.
Recomendation: Use
          polymorphic_get or polymorphic_strict_get
          in new code.
          polymorphic_strict_get
          provides more compile time checks and its behavior is closer to std::get
          from C++ Standard Library.
Warning: After either
          operand or its content is destroyed (e.g., when the
          given variant is assigned a
          value of different type), the returned reference is invalidated.
          Thus, significant care and caution must be extended when handling
          the returned reference.
| Notes: | As part of its guarantee of type-safety, polymorphic_getenforcesconst-correctness. Thus, the specified typeUmust beconst-qualified wheneveroperandor its content is likewiseconst-qualified. The converse, however, is not required:
        that is, the specified typeUmay beconst-qualified even whenoperandand its
        content are not. | 
| Returns: | If passed a pointer, polymorphic_getreturns a pointer to
        the value content if it is of the specified typeUor of type
        derived from typeU;
        otherwise, a null pointer is returned. If passed a reference,polymorphic_getreturns a reference to the value content if it is of
        the specified typeUor of type
          derived from typeU; otherwise, an exception is thrown
        (see below). | 
| Throws: | Overloads taking a variantpointer will not
        throw; the overloads taking avariantreference throwbad_polymorphic_getif the content is not of
        the specified typeUor of type
        derived from typeU. | 
| Rationale: | While visitation via apply_visitoris generally preferred due to its greater safety,polymorphic_getmay
        may be more convenient in some cases due to its straightforward
        usage. |