os/ossrv/ossrv_pub/boost_apis/boost/mpl/apply_wrap.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
sl@0
     2
#if !defined(BOOST_PP_IS_ITERATING)
sl@0
     3
sl@0
     4
///// header body
sl@0
     5
sl@0
     6
#ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
sl@0
     7
#define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
sl@0
     8
sl@0
     9
// Copyright Aleksey Gurtovoy 2000-2004
sl@0
    10
//
sl@0
    11
// Distributed under the Boost Software License, Version 1.0. 
sl@0
    12
// (See accompanying file LICENSE_1_0.txt or copy at 
sl@0
    13
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    14
//
sl@0
    15
// See http://www.boost.org/libs/mpl for documentation.
sl@0
    16
sl@0
    17
// $Source: /cvsroot/boost/boost/boost/mpl/apply_wrap.hpp,v $
sl@0
    18
// $Date: 2004/09/03 15:56:55 $
sl@0
    19
// $Revision: 1.3 $
sl@0
    20
sl@0
    21
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
sl@0
    22
#   include <boost/mpl/aux_/arity.hpp>
sl@0
    23
#   include <boost/mpl/aux_/has_apply.hpp>
sl@0
    24
#   include <boost/mpl/aux_/na.hpp>
sl@0
    25
#   include <boost/mpl/aux_/msvc_never_true.hpp>
sl@0
    26
#endif
sl@0
    27
sl@0
    28
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
sl@0
    29
sl@0
    30
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
sl@0
    31
    && !defined(BOOST_MPL_PREPROCESSING_MODE)
sl@0
    32
sl@0
    33
#   define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
sl@0
    34
#   include <boost/mpl/aux_/include_preprocessed.hpp>
sl@0
    35
sl@0
    36
#else
sl@0
    37
sl@0
    38
#   include <boost/mpl/limits/arity.hpp>
sl@0
    39
#   include <boost/mpl/aux_/preprocessor/params.hpp>
sl@0
    40
#   include <boost/mpl/aux_/preprocessor/enum.hpp>
sl@0
    41
#   include <boost/mpl/aux_/preprocessor/add.hpp>
sl@0
    42
#   include <boost/mpl/aux_/config/dtp.hpp>
sl@0
    43
#   include <boost/mpl/aux_/config/eti.hpp>
sl@0
    44
#   include <boost/mpl/aux_/config/ctps.hpp>
sl@0
    45
#   include <boost/mpl/aux_/config/msvc.hpp>
sl@0
    46
#   include <boost/mpl/aux_/config/workaround.hpp>
sl@0
    47
sl@0
    48
#   include <boost/preprocessor/comma_if.hpp>
sl@0
    49
#   include <boost/preprocessor/logical/and.hpp>
sl@0
    50
#   include <boost/preprocessor/inc.hpp>
sl@0
    51
#   include <boost/preprocessor/iterate.hpp>
sl@0
    52
sl@0
    53
sl@0
    54
namespace boost { namespace mpl {
sl@0
    55
sl@0
    56
// local macros, #undef-ined at the end of the header
sl@0
    57
#   define AUX778076_APPLY_WRAP_PARAMS(n, param) \
sl@0
    58
    BOOST_MPL_PP_PARAMS(n, param) \
sl@0
    59
    /**/
sl@0
    60
sl@0
    61
#   define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
sl@0
    62
    BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
sl@0
    63
    /**/
sl@0
    64
sl@0
    65
sl@0
    66
#define BOOST_PP_ITERATION_PARAMS_1 \
sl@0
    67
    (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply_wrap.hpp>))
sl@0
    68
#include BOOST_PP_ITERATE()
sl@0
    69
sl@0
    70
sl@0
    71
#   undef AUX778076_APPLY_WRAP_SPEC_PARAMS
sl@0
    72
#   undef AUX778076_APPLY_WRAP_PARAMS
sl@0
    73
sl@0
    74
}}
sl@0
    75
sl@0
    76
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
sl@0
    77
#endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
sl@0
    78
sl@0
    79
///// iteration, depth == 1
sl@0
    80
sl@0
    81
#elif BOOST_PP_ITERATION_DEPTH() == 1
sl@0
    82
sl@0
    83
#   define i_ BOOST_PP_FRAME_ITERATION(1)
sl@0
    84
sl@0
    85
#   if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
sl@0
    86
// MSVC version
sl@0
    87
sl@0
    88
#define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_)
sl@0
    89
#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
sl@0
    90
#define AUX778076_MSVC_DTW_ARITY i_
sl@0
    91
#include <boost/mpl/aux_/msvc_dtw.hpp>
sl@0
    92
sl@0
    93
template<
sl@0
    94
      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
sl@0
    95
    >
sl@0
    96
struct BOOST_PP_CAT(apply_wrap,i_)
sl@0
    97
{
sl@0
    98
    // Metafunction forwarding confuses vc6
sl@0
    99
    typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
sl@0
   100
          AUX778076_APPLY_WRAP_PARAMS(i_, T)
sl@0
   101
        >::type type;
sl@0
   102
};
sl@0
   103
sl@0
   104
#   elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
sl@0
   105
// MWCW/Borland version
sl@0
   106
sl@0
   107
template<
sl@0
   108
      int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
sl@0
   109
    >
sl@0
   110
struct BOOST_PP_CAT(apply_wrap_impl,i_);
sl@0
   111
sl@0
   112
#define BOOST_PP_ITERATION_PARAMS_2 \
sl@0
   113
    (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <boost/mpl/apply_wrap.hpp>))
sl@0
   114
#include BOOST_PP_ITERATE()
sl@0
   115
sl@0
   116
template<
sl@0
   117
      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
sl@0
   118
    >
sl@0
   119
struct BOOST_PP_CAT(apply_wrap,i_)
sl@0
   120
    : BOOST_PP_CAT(apply_wrap_impl,i_)<
sl@0
   121
          ::boost::mpl::aux::arity<F,i_>::value
sl@0
   122
        , F
sl@0
   123
        BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
sl@0
   124
        >::type
sl@0
   125
{
sl@0
   126
};
sl@0
   127
sl@0
   128
#   else
sl@0
   129
// ISO98 C++, with minor concession to vc7
sl@0
   130
sl@0
   131
template<
sl@0
   132
      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
sl@0
   133
#if i_ == 0
sl@0
   134
    , typename has_apply_ = typename aux::has_apply<F>::type
sl@0
   135
#endif
sl@0
   136
    >
sl@0
   137
struct BOOST_PP_CAT(apply_wrap,i_)
sl@0
   138
// metafunction forwarding confuses MSVC 7.0
sl@0
   139
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1300)
sl@0
   140
    : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
sl@0
   141
{
sl@0
   142
#else
sl@0
   143
{    
sl@0
   144
    typedef typename F::template apply<
sl@0
   145
         AUX778076_APPLY_WRAP_PARAMS(i_, T)
sl@0
   146
        >::type type;
sl@0
   147
#endif
sl@0
   148
};
sl@0
   149
sl@0
   150
#if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
sl@0
   151
template< typename F >
sl@0
   152
struct BOOST_PP_CAT(apply_wrap,i_)<F,true_>
sl@0
   153
    : F::apply
sl@0
   154
{
sl@0
   155
};
sl@0
   156
#endif
sl@0
   157
sl@0
   158
#   endif // workarounds
sl@0
   159
sl@0
   160
#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
sl@0
   161
/// workaround for ETI bug
sl@0
   162
template<>
sl@0
   163
struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
sl@0
   164
{
sl@0
   165
    typedef int type;
sl@0
   166
};
sl@0
   167
#endif
sl@0
   168
sl@0
   169
#   undef i_
sl@0
   170
sl@0
   171
///// iteration, depth == 2
sl@0
   172
sl@0
   173
#elif BOOST_PP_ITERATION_DEPTH() == 2
sl@0
   174
sl@0
   175
#   define j_ BOOST_PP_FRAME_ITERATION(2)
sl@0
   176
sl@0
   177
template<
sl@0
   178
      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
sl@0
   179
    >
sl@0
   180
struct BOOST_PP_CAT(apply_wrap_impl,i_)<
sl@0
   181
          BOOST_MPL_PP_ADD(i_, j_)
sl@0
   182
        , F
sl@0
   183
        BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
sl@0
   184
        >
sl@0
   185
{
sl@0
   186
    typedef typename F::template apply<
sl@0
   187
          AUX778076_APPLY_WRAP_PARAMS(i_, T)
sl@0
   188
#if i_ == 0 && j_ == 0
sl@0
   189
/// since the defaults are "lost", we have to pass *something* even for nullary
sl@0
   190
/// metafunction classes
sl@0
   191
        na
sl@0
   192
#else
sl@0
   193
        BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na)
sl@0
   194
#endif
sl@0
   195
        > type;
sl@0
   196
};
sl@0
   197
sl@0
   198
#   undef j_
sl@0
   199
sl@0
   200
#endif // BOOST_PP_IS_ITERATING