Safe, generic, stack-based discriminated union container. The variant class template (inspired by Andrei Alexandrescu's class of the same name [Ale01A]) is an efficient, recursive-capable, bounded discriminated union value type capable of containing any value type (either POD or non-POD). It supports construction from any type convertible to one of its bounded types or from a source variant whose bounded types are each convertible to one of the destination variant's bounded types. As well, through apply_visitor, variant supports compile-time checked, type-safe visitation; and through get, variant supports run-time checked, type-safe value retrieval. Notes: All members of variant satisfy at least the strong guarantee of exception-safety with respect to the type of the contained value. That is, a failed operation on a variant will never cause the type of the content to change. Each type specified as a template argument to variant must meet the requirements of the BoundedType concept. Each type specified as a template argument to variant must be distinct. For instance, use of variant<int, int> or variant<int, const int> results in undefined behavior. Conforming implementations of variant must allow at least ten types as template arguments. The exact number of allowed arguments is exposed by the preprocessor macro BOOST_VARIANT_LIMIT_TYPES. The following syntax is also supported: variant< type-sequence >, where type-sequence must meet the requirements of the MPL's Sequence concept. For instance, variant< mpl::list<int, std::string> > is functionally equivalent to variant< int, std::string >. (Due to standard conformance problems in several compilers, however, this syntax may not be supported on your compiler. See BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT for more information.) unspecified T1, T2, ..., TN as an MPL-compatible Sequence. Destructor. Destroys *this, also destroying its currently contained value. Will not throw. Default constructor. Initializes *this with the default value of the first bounded type (i.e, T1). The first bounded type of the variant (i.e., T1) must fulfill the requirements of the DefaultConstructible concept. May fail with any exceptions arising from the default constructor of T1. const variant & Copy constructor. Copies the content of other into *this. May fail with any exceptions arising from the copy constructor of other's contained type. const T & Templated constructor. If T is one of the bounded types of the variant, then initializes *this with a copy of operand. Otherwise, uses standard overload resolution rules to find the best conversion from T to a bounded type, and initializes *this with a copy of the converted operand. If the conversion to a bounded type is ambiguous, or if none exists, a compiler error results. If T is one of the bounded types of the variant, may fail with any exceptions arising from the copy constructor of T. Otherwise, may fail with any exceptions arising from the conversion to a bounded type. const variant<U1, U2, ..., UN> & Templated conversion constructor. If variant<U1, U2, ..., UN> is itself one of the bounded types of the variant, then initializes *this with a copy of operand. Otherwise, uses standard overload resolution rules to find the best conversion from the content of operand to a bounded type, and initializes *this with a copy of the converted value. If the conversion from any of U1, U2, ..., UN to a bounded type (i.e., T1, T2, ..., TN) is ambiguous, or if none exists, a compiler error results. If variant<U1, U2, ..., UN> is itself one of the bounded types of the variant, then may fail with any exceptions arising from the copy constructor of variant<U1, U2, ..., UN>. Otherwise, may fail with any exceptions arising from the conversion to a bounded type. void variant & Exchanges contents of *this and other. Every bounded type of the variant must fulfill the requirements of the Assignable concept. May fail with any exceptions arising from the copy constructors of the contained types of *this or other; or, if the contained types are the same, from the swap primitive for the type. variant & const variant & Copy assignment operator. If the contained type of rhs is the same as the contained type of *this, then assigns the contained value of rhs into the contained value of *this. Otherwise, copies the contained value of rhs into *this (destroying the previously contained value of *this). Every bounded type of the variant must fulfill the requirements of the Assignable concept. May fail with any exceptions arising from either the copy constructor or the assignment operator of the contained type of rhs. variant & const T & Templated assignment operator. First, converts rhs into a variant (see above conversion constructors). Next, if the contained type of the converted rhs is the same as the contained type of *this, then assigns the contained value of the converted rhs into the contained value of *this. Otherwise, copies the contained value of the converted rhs into *this (destroying the previously contained value of *this). Every bounded type of the variant must fulfill the requirements of the Assignable concept. If T is itself a bounded type of variant, then may fail with any exceptions arising from the copy constructor of T. Otherwise, may fail with any exceptions arising from the conversion to a bounded type or from its copy constructor or assignment operator. int Returns the zero-based index of the bounded type of the contained value. (For example, if called on a variant<int, std::string> object containing a std::string, which() would return 1.) Will not throw. bool Returns true if and only if the type of the content is boost::empty. Will not throw. const std::type_info & Returns the typeid() of the contained value. Will not throw. void variant<T1, T2, ..., TN> & variant<T1, T2, ..., TN> & Swaps the given variant objects. Swaps lhs with rhs by application of variant::swap. May fail with any exception arising from variant::swap. std::basic_ostream<ElemType,Traits> & std::basic_ostream<ElemType,Traits> & const variant<T1, T2, ..., TN> & Streaming output operator for variant. Outputs the content of rhs to out by application of operator<< to the content. Every bounded type of the variant must fulfill the requirements of the OutputStreamable concept.