os/ossrv/ossrv_pub/boost_apis/boost/variant/variant_fwd.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
//-----------------------------------------------------------------------------
sl@0
     2
// boost variant/variant_fwd.hpp header file
sl@0
     3
// See http://www.boost.org for updates, documentation, and revision history.
sl@0
     4
//-----------------------------------------------------------------------------
sl@0
     5
//
sl@0
     6
// Copyright (c) 2003
sl@0
     7
// Eric Friedman, Itay Maman
sl@0
     8
//
sl@0
     9
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
    10
// accompanying file LICENSE_1_0.txt or copy at
sl@0
    11
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    12
sl@0
    13
#ifndef BOOST_VARIANT_VARIANT_FWD_HPP
sl@0
    14
#define BOOST_VARIANT_VARIANT_FWD_HPP
sl@0
    15
sl@0
    16
#include "boost/variant/detail/config.hpp"
sl@0
    17
sl@0
    18
#include "boost/blank_fwd.hpp"
sl@0
    19
#include "boost/mpl/arg.hpp"
sl@0
    20
#include "boost/mpl/limits/arity.hpp"
sl@0
    21
#include "boost/mpl/aux_/na.hpp"
sl@0
    22
#include "boost/preprocessor/cat.hpp"
sl@0
    23
#include "boost/preprocessor/enum.hpp"
sl@0
    24
#include "boost/preprocessor/enum_params.hpp"
sl@0
    25
#include "boost/preprocessor/enum_shifted_params.hpp"
sl@0
    26
#include "boost/preprocessor/repeat.hpp"
sl@0
    27
sl@0
    28
///////////////////////////////////////////////////////////////////////////////
sl@0
    29
// macro BOOST_VARIANT_LIMIT_TYPES
sl@0
    30
//
sl@0
    31
// Implementation-defined preprocessor symbol describing the actual
sl@0
    32
// length of variant's pseudo-variadic template parameter list.
sl@0
    33
//
sl@0
    34
#include "boost/mpl/limits/list.hpp"
sl@0
    35
#define BOOST_VARIANT_LIMIT_TYPES \
sl@0
    36
    BOOST_MPL_LIMIT_LIST_SIZE
sl@0
    37
sl@0
    38
///////////////////////////////////////////////////////////////////////////////
sl@0
    39
// macro BOOST_VARIANT_NO_REFERENCE_SUPPORT
sl@0
    40
//
sl@0
    41
// Defined if variant does not support references as bounded types. 
sl@0
    42
//
sl@0
    43
#if defined(BOOST_VARIANT_AUX_BROKEN_CONSTRUCTOR_TEMPLATE_ORDERING) \
sl@0
    44
 && !defined(BOOST_VARIANT_AUX_HAS_CONSTRUCTOR_TEMPLATE_ORDERING_SFINAE_WKND) \
sl@0
    45
 && !defined(BOOST_VARIANT_NO_REFERENCE_SUPPORT)
sl@0
    46
#   define BOOST_VARIANT_NO_REFERENCE_SUPPORT
sl@0
    47
#endif
sl@0
    48
sl@0
    49
///////////////////////////////////////////////////////////////////////////////
sl@0
    50
// macro BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
sl@0
    51
//
sl@0
    52
// Defined if variant does not support make_variant_over (see below). 
sl@0
    53
//
sl@0
    54
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
sl@0
    55
#   define BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
sl@0
    56
#endif
sl@0
    57
sl@0
    58
///////////////////////////////////////////////////////////////////////////////
sl@0
    59
// macro BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
sl@0
    60
//
sl@0
    61
// Defined if make_recursive_variant cannot be supported as documented.
sl@0
    62
//
sl@0
    63
// Note: Currently, MPL lambda facility is used as workaround if defined, and
sl@0
    64
// so only types declared w/ MPL lambda workarounds will work.
sl@0
    65
//
sl@0
    66
sl@0
    67
#include "boost/variant/detail/substitute_fwd.hpp"
sl@0
    68
sl@0
    69
#if defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE) \
sl@0
    70
 && !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
sl@0
    71
#   define BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
sl@0
    72
#endif
sl@0
    73
sl@0
    74
///////////////////////////////////////////////////////////////////////////////
sl@0
    75
// macro BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY
sl@0
    76
//
sl@0
    77
// Exposes maximum allowed arity of class templates with recursive_variant
sl@0
    78
// arguments. That is,
sl@0
    79
//   make_recursive_variant< ..., T<[1], recursive_variant_, ... [N]> >.
sl@0
    80
//
sl@0
    81
#include "boost/mpl/limits/arity.hpp"
sl@0
    82
#define BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY \
sl@0
    83
    BOOST_MPL_LIMIT_METAFUNCTION_ARITY
sl@0
    84
sl@0
    85
///////////////////////////////////////////////////////////////////////////////
sl@0
    86
// macro BOOST_VARIANT_ENUM_PARAMS
sl@0
    87
//
sl@0
    88
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES params.
sl@0
    89
//
sl@0
    90
// Rationale: Cleaner, simpler code for clients of variant library.
sl@0
    91
//
sl@0
    92
#define BOOST_VARIANT_ENUM_PARAMS( param )  \
sl@0
    93
    BOOST_PP_ENUM_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
sl@0
    94
sl@0
    95
///////////////////////////////////////////////////////////////////////////////
sl@0
    96
// macro BOOST_VARIANT_ENUM_SHIFTED_PARAMS
sl@0
    97
//
sl@0
    98
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES-1 params.
sl@0
    99
//
sl@0
   100
#define BOOST_VARIANT_ENUM_SHIFTED_PARAMS( param )  \
sl@0
   101
    BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
sl@0
   102
sl@0
   103
sl@0
   104
namespace boost {
sl@0
   105
sl@0
   106
namespace detail { namespace variant {
sl@0
   107
sl@0
   108
///////////////////////////////////////////////////////////////////////////////
sl@0
   109
// (detail) class void_ and class template convert_void
sl@0
   110
// 
sl@0
   111
// Provides the mechanism by which void(NN) types are converted to
sl@0
   112
// mpl::void_ (and thus can be passed to mpl::list).
sl@0
   113
//
sl@0
   114
// Rationale: This is particularly needed for the using-declarations
sl@0
   115
// workaround (below), but also to avoid associating mpl namespace with
sl@0
   116
// variant in argument dependent lookups (which used to happen because of
sl@0
   117
// defaulting of template parameters to mpl::void_).
sl@0
   118
//
sl@0
   119
sl@0
   120
struct void_;
sl@0
   121
sl@0
   122
template <typename T>
sl@0
   123
struct convert_void
sl@0
   124
{
sl@0
   125
    typedef T type;
sl@0
   126
};
sl@0
   127
sl@0
   128
template <>
sl@0
   129
struct convert_void< void_ >
sl@0
   130
{
sl@0
   131
    typedef mpl::na type;
sl@0
   132
};
sl@0
   133
sl@0
   134
///////////////////////////////////////////////////////////////////////////////
sl@0
   135
// (workaround) BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE
sl@0
   136
//
sl@0
   137
// Needed to work around compilers that don't support using-declaration
sl@0
   138
// overloads. (See the variant::initializer workarounds below.)
sl@0
   139
//
sl@0
   140
sl@0
   141
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
sl@0
   142
sl@0
   143
// (detail) tags voidNN -- NN defined on [0, BOOST_VARIANT_LIMIT_TYPES)
sl@0
   144
//
sl@0
   145
// Defines void types that are each unique and specializations of
sl@0
   146
// convert_void that yields mpl::na for each voidNN type.
sl@0
   147
//
sl@0
   148
sl@0
   149
#define BOOST_VARIANT_DETAIL_DEFINE_VOID_N(z,N,_)          \
sl@0
   150
    struct BOOST_PP_CAT(void,N);                           \
sl@0
   151
                                                           \
sl@0
   152
    template <>                                            \
sl@0
   153
    struct convert_void< BOOST_PP_CAT(void,N) >            \
sl@0
   154
    {                                                      \
sl@0
   155
        typedef mpl::na type;                              \
sl@0
   156
    };                                                     \
sl@0
   157
    /**/
sl@0
   158
sl@0
   159
BOOST_PP_REPEAT(
sl@0
   160
      BOOST_VARIANT_LIMIT_TYPES
sl@0
   161
    , BOOST_VARIANT_DETAIL_DEFINE_VOID_N
sl@0
   162
    , _
sl@0
   163
    )
sl@0
   164
sl@0
   165
#undef BOOST_VARIANT_DETAIL_DEFINE_VOID_N
sl@0
   166
sl@0
   167
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
sl@0
   168
sl@0
   169
}} // namespace detail::variant
sl@0
   170
sl@0
   171
///////////////////////////////////////////////////////////////////////////////
sl@0
   172
// (detail) macro BOOST_VARIANT_AUX_DECLARE_PARAM
sl@0
   173
//
sl@0
   174
// Template parameter list for variant and recursive_variant declarations.
sl@0
   175
//
sl@0
   176
sl@0
   177
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
sl@0
   178
sl@0
   179
#   define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
sl@0
   180
    typename BOOST_PP_CAT(T,N) = detail::variant::void_ \
sl@0
   181
    /**/
sl@0
   182
sl@0
   183
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
sl@0
   184
sl@0
   185
#   define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
sl@0
   186
    typename BOOST_PP_CAT(T,N) = BOOST_PP_CAT(detail::variant::void,N) \
sl@0
   187
    /**/
sl@0
   188
sl@0
   189
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
sl@0
   190
sl@0
   191
#define BOOST_VARIANT_AUX_DECLARE_PARAMS \
sl@0
   192
    BOOST_PP_ENUM( \
sl@0
   193
          BOOST_VARIANT_LIMIT_TYPES \
sl@0
   194
        , BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL \
sl@0
   195
        , T \
sl@0
   196
        ) \
sl@0
   197
    /**/
sl@0
   198
sl@0
   199
///////////////////////////////////////////////////////////////////////////////
sl@0
   200
// class template variant (concept inspired by Andrei Alexandrescu)
sl@0
   201
//
sl@0
   202
// Efficient, type-safe bounded discriminated union.
sl@0
   203
//
sl@0
   204
// Preconditions:
sl@0
   205
//  - Each type must be unique.
sl@0
   206
//  - No type may be const-qualified.
sl@0
   207
//
sl@0
   208
// Proper declaration form:
sl@0
   209
//   variant<types>    (where types is a type-sequence)
sl@0
   210
// or
sl@0
   211
//   variant<T0,T1,...,Tn>  (where T0 is NOT a type-sequence)
sl@0
   212
//
sl@0
   213
template < BOOST_VARIANT_AUX_DECLARE_PARAMS > class variant;
sl@0
   214
sl@0
   215
///////////////////////////////////////////////////////////////////////////////
sl@0
   216
// metafunction make_recursive_variant
sl@0
   217
//
sl@0
   218
// Exposes a boost::variant with recursive_variant_ tags (below) substituted
sl@0
   219
// with the variant itself (wrapped as needed with boost::recursive_wrapper).
sl@0
   220
//
sl@0
   221
template < BOOST_VARIANT_AUX_DECLARE_PARAMS > struct make_recursive_variant;
sl@0
   222
sl@0
   223
#undef BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL
sl@0
   224
#undef BOOST_VARIANT_AUX_DECLARE_PARAMS
sl@0
   225
sl@0
   226
///////////////////////////////////////////////////////////////////////////////
sl@0
   227
// type recursive_variant_
sl@0
   228
//
sl@0
   229
// Tag type indicates where recursive variant substitution should occur.
sl@0
   230
//
sl@0
   231
#if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
sl@0
   232
    struct recursive_variant_;
sl@0
   233
#else
sl@0
   234
    typedef mpl::arg<1> recursive_variant_;
sl@0
   235
#endif
sl@0
   236
sl@0
   237
///////////////////////////////////////////////////////////////////////////////
sl@0
   238
// metafunction make_variant_over
sl@0
   239
//
sl@0
   240
// Result is a variant w/ types of the specified type sequence.
sl@0
   241
//
sl@0
   242
template <typename Types> struct make_variant_over;
sl@0
   243
sl@0
   244
///////////////////////////////////////////////////////////////////////////////
sl@0
   245
// metafunction make_recursive_variant_over
sl@0
   246
//
sl@0
   247
// Result is a recursive variant w/ types of the specified type sequence.
sl@0
   248
//
sl@0
   249
template <typename Types> struct make_recursive_variant_over;
sl@0
   250
sl@0
   251
} // namespace boost
sl@0
   252
sl@0
   253
#endif // BOOST_VARIANT_VARIANT_FWD_HPP