Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:10:52

0001 //-----------------------------------------------------------------------------
0002 // boost variant/variant_fwd.hpp header file
0003 // See http://www.boost.org for updates, documentation, and revision history.
0004 //-----------------------------------------------------------------------------
0005 //
0006 // Copyright (c) 2003 Eric Friedman, Itay Maman
0007 // Copyright (c) 2013-2025 Antony Polukhin
0008 //
0009 // Distributed under the Boost Software License, Version 1.0. (See
0010 // accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_VARIANT_VARIANT_FWD_HPP
0014 #define BOOST_VARIANT_VARIANT_FWD_HPP
0015 
0016 #include <boost/variant/detail/config.hpp>
0017 
0018 #include <boost/blank_fwd.hpp>
0019 #include <boost/mpl/arg.hpp>
0020 #include <boost/mpl/limits/arity.hpp>
0021 #include <boost/mpl/aux_/na.hpp>
0022 #include <boost/preprocessor/cat.hpp>
0023 #include <boost/preprocessor/enum.hpp>
0024 #include <boost/preprocessor/enum_params.hpp>
0025 #include <boost/preprocessor/enum_shifted_params.hpp>
0026 #include <boost/preprocessor/repeat.hpp>
0027 
0028 ///////////////////////////////////////////////////////////////////////////////
0029 // macro BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
0030 //
0031 // Defined if make_recursive_variant cannot be supported as documented.
0032 //
0033 // Note: Currently, MPL lambda facility is used as workaround if defined, and
0034 // so only types declared w/ MPL lambda workarounds will work.
0035 //
0036 
0037 #include <boost/variant/detail/substitute_fwd.hpp>
0038 
0039 #include <boost/preprocessor/seq/size.hpp>
0040 
0041 #define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_class class)(
0042 #define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_typename typename)(
0043 
0044 #define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_class class...
0045 #define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_typename typename...
0046 
0047 #define ARGS_VARIADER_1(x) x ## N...
0048 #define ARGS_VARIADER_2(x) BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_ ## x ## N
0049 
0050 #define BOOST_VARIANT_MAKE_VARIADIC(sequence, x)        BOOST_VARIANT_MAKE_VARIADIC_I(BOOST_PP_SEQ_SIZE(sequence), x)
0051 #define BOOST_VARIANT_MAKE_VARIADIC_I(argscount, x)     BOOST_VARIANT_MAKE_VARIADIC_II(argscount, x)
0052 #define BOOST_VARIANT_MAKE_VARIADIC_II(argscount, orig) ARGS_VARIADER_ ## argscount(orig)
0053 
0054 ///////////////////////////////////////////////////////////////////////////////
0055 // BOOST_VARIANT_ENUM_PARAMS and BOOST_VARIANT_ENUM_SHIFTED_PARAMS
0056 //
0057 // Convenience macro for enumeration of variant params.
0058 // When variadic templates are available expands:
0059 //      BOOST_VARIANT_ENUM_PARAMS(class Something)      => class Something0, class... SomethingN
0060 //      BOOST_VARIANT_ENUM_PARAMS(typename Something)   => typename Something0, typename... SomethingN
0061 //      BOOST_VARIANT_ENUM_PARAMS(Something)            => Something0, SomethingN...
0062 //      BOOST_VARIANT_ENUM_PARAMS(Something)            => Something0, SomethingN...
0063 //      BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class Something)      => class... SomethingN
0064 //      BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename Something)   => typename... SomethingN
0065 //      BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something)            => SomethingN...
0066 //      BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something)            => SomethingN...
0067 //
0068 // Rationale: Cleaner, simpler code for clients of variant library. Minimal 
0069 // code modifications to move from C++03 to C++11.
0070 //
0071 
0072 #define BOOST_VARIANT_ENUM_PARAMS(x) \
0073     x ## 0, \
0074     BOOST_VARIANT_MAKE_VARIADIC( (BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_ ## x), x) \
0075     /**/
0076 
0077 #define BOOST_VARIANT_ENUM_SHIFTED_PARAMS(x) \
0078     BOOST_VARIANT_MAKE_VARIADIC( (BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_ ## x), x) \
0079     /**/
0080 
0081 
0082 namespace boost {
0083 
0084 namespace detail { namespace variant {
0085 
0086 ///////////////////////////////////////////////////////////////////////////////
0087 // (detail) class void_ and class template convert_void
0088 // 
0089 // Provides the mechanism by which void(NN) types are converted to
0090 // mpl::void_ (and thus can be passed to mpl::list).
0091 //
0092 // Rationale: This is particularly needed for the using-declarations
0093 // workaround (below), but also to avoid associating mpl namespace with
0094 // variant in argument dependent lookups (which used to happen because of
0095 // defaulting of template parameters to mpl::void_).
0096 //
0097 
0098 struct void_;
0099 
0100 template <typename T>
0101 struct convert_void
0102 {
0103     typedef T type;
0104 };
0105 
0106 template <>
0107 struct convert_void< void_ >
0108 {
0109     typedef mpl::na type;
0110 };
0111 
0112 }} // namespace detail::variant
0113 
0114 #define BOOST_VARIANT_AUX_DECLARE_PARAMS BOOST_VARIANT_ENUM_PARAMS(typename T)
0115 
0116 ///////////////////////////////////////////////////////////////////////////////
0117 // class template variant (concept inspired by Andrei Alexandrescu)
0118 //
0119 // Efficient, type-safe bounded discriminated union.
0120 //
0121 // Preconditions:
0122 //  - Each type must be unique.
0123 //  - No type may be const-qualified.
0124 //
0125 // Proper declaration form:
0126 //   variant<types>    (where types is a type-sequence)
0127 // or
0128 //   variant<T0,T1,...,Tn>  (where T0 is NOT a type-sequence)
0129 //
0130 template < BOOST_VARIANT_AUX_DECLARE_PARAMS > class variant;
0131 
0132 ///////////////////////////////////////////////////////////////////////////////
0133 // metafunction make_recursive_variant
0134 //
0135 // Exposes a boost::variant with recursive_variant_ tags (below) substituted
0136 // with the variant itself (wrapped as needed with boost::recursive_wrapper).
0137 //
0138 template < BOOST_VARIANT_AUX_DECLARE_PARAMS > struct make_recursive_variant;
0139 
0140 #undef BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL
0141 #undef BOOST_VARIANT_AUX_DECLARE_PARAMS
0142 
0143 ///////////////////////////////////////////////////////////////////////////////
0144 // type recursive_variant_
0145 //
0146 // Tag type indicates where recursive variant substitution should occur.
0147 //
0148 #if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
0149     struct recursive_variant_ {};
0150 #else
0151     typedef mpl::arg<1> recursive_variant_;
0152 #endif
0153 
0154 ///////////////////////////////////////////////////////////////////////////////
0155 // metafunction make_variant_over
0156 //
0157 // Result is a variant w/ types of the specified type sequence.
0158 //
0159 template <typename Types> struct make_variant_over;
0160 
0161 ///////////////////////////////////////////////////////////////////////////////
0162 // metafunction make_recursive_variant_over
0163 //
0164 // Result is a recursive variant w/ types of the specified type sequence.
0165 //
0166 template <typename Types> struct make_recursive_variant_over;
0167 
0168 } // namespace boost
0169 
0170 #endif // BOOST_VARIANT_VARIANT_FWD_HPP