Home | Libraries | People | FAQ | More |
The requirements on a bounded type are as follows:
Every type specified as a template argument to variant must at minimum fulfill the above requirements. In addition, certain features of variant are available only if its bounded types meet the requirements of these following additional concepts:
The requirements on a static visitor of a type T are as follows:
The following class satisfies the requirements of a static visitor of several types (i.e., explicitly: int and std::string; or, e.g., implicitly: short and const char *; etc.):
class my_visitor : public boost::static_visitor<int> { public: int operator()(int i) { return i * 2; } int operator()(const std::string& s) { return s.length(); } };
Another example is the following class, whose function-call operator is a member template, allowing it to operate on values of many types. Thus, the following class is a visitor of any type that supports streaming output (e.g., int, double, std::string, etc.):
class printer : public boost::static_visitor<> { template <typename T> void operator()(const T& t) { std::cout << t << std::endl; } };
This header exists simply as a convenience to the user, including all of the headers in the boost/variant directory.
Provides forward declarations of the boost::variant, boost::make_variant_over, boost::make_recursive_variant, and boost::make_recursive_variant_over class templates and the boost::recursive_variant_ tag type. Also defines several preprocessor symbols, as described below.
BOOST_VARIANT_LIMIT_TYPES BOOST_VARIANT_ENUM_PARAMS(param) BOOST_VARIANT_ENUM_SHIFTED_PARAMS(param) BOOST_VARIANT_NO_REFERENCE_SUPPORT BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
namespace boost { template<typename T1, typename T2 = unspecified, ..., typename TN = unspecified> class variant; template<typename Sequence> class make_variant_over; template<typename T1, typename T2, ..., typename TN> void swap(variant<T1, T2, ..., TN> &, variant<T1, T2, ..., TN> &); template<typename ElemType, typename Traits, typename T1, typename T2, ..., typename TN> std::basic_ostream<ElemType,Traits> & operator<<(std::basic_ostream<ElemType,Traits> &, const variant<T1, T2, ..., TN> &); }
namespace boost { typedef unspecified recursive_variant_; template<typename T1, typename T2 = unspecified, ..., typename TN = unspecified> class make_recursive_variant; template<typename Sequence> class make_recursive_variant_over; }
namespace boost { template<typename T> class recursive_wrapper; template<typename T> class is_recursive_wrapper; template<typename T> class unwrap_recursive_wrapper; }
namespace boost { template<typename Visitor> class apply_visitor_delayed_t; template<typename Visitor, typename Variant> typename Visitor::result_type apply_visitor(Visitor &, Variant &); template<typename Visitor, typename Variant> typename Visitor::result_type apply_visitor(const Visitor &, Variant &); template<typename BinaryVisitor, typename Variant1, typename Variant2> typename BinaryVisitor::result_type apply_visitor(BinaryVisitor &, Variant1 &, Variant2 &); template<typename BinaryVisitor, typename Variant1, typename Variant2> typename BinaryVisitor::result_type apply_visitor(const BinaryVisitor &, Variant1 &, Variant2 &); template<typename Visitor> apply_visitor_delayed_t<Visitor> apply_visitor(Visitor &); }
namespace boost { class bad_get; template<typename U, typename T1, typename T2, ..., typename TN> U * get(variant<T1, T2, ..., TN> *); template<typename U, typename T1, typename T2, ..., typename TN> const U * get(const variant<T1, T2, ..., TN> *); template<typename U, typename T1, typename T2, ..., typename TN> U & get(variant<T1, T2, ..., TN> &); template<typename U, typename T1, typename T2, ..., typename TN> const U & get(const variant<T1, T2, ..., TN> &); }
namespace boost { class bad_visit; }
namespace boost { template<typename ResultType> class static_visitor; }
namespace boost { template<typename T, typename R> class visitor_ptr_t; template<typename R, typename T> visitor_ptr_t<T,R> visitor_ptr(R (*)(T)); }
Copyright © 2002, 2003 Eric Friedman, Itay Maman |