os/ossrv/ossrv_pub/boost_apis/boost/mpl/inherit.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
#if !defined(BOOST_PP_IS_ITERATING)
sl@0
     3
sl@0
     4
///// header body
sl@0
     5
sl@0
     6
#ifndef BOOST_MPL_INHERIT_HPP_INCLUDED
sl@0
     7
#define BOOST_MPL_INHERIT_HPP_INCLUDED
sl@0
     8
sl@0
     9
// Copyright Aleksey Gurtovoy 2001-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/inherit.hpp,v $
sl@0
    18
// $Date: 2004/09/02 15:40:41 $
sl@0
    19
// $Revision: 1.5 $
sl@0
    20
sl@0
    21
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
sl@0
    22
#   include <boost/mpl/empty_base.hpp>
sl@0
    23
#   include <boost/mpl/aux_/na_spec.hpp>
sl@0
    24
#   include <boost/mpl/aux_/lambda_support.hpp>
sl@0
    25
#endif
sl@0
    26
sl@0
    27
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
sl@0
    28
sl@0
    29
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
sl@0
    30
    && !defined(BOOST_MPL_PREPROCESSING_MODE)
sl@0
    31
sl@0
    32
#   define BOOST_MPL_PREPROCESSED_HEADER inherit.hpp
sl@0
    33
#   include <boost/mpl/aux_/include_preprocessed.hpp>
sl@0
    34
sl@0
    35
#else
sl@0
    36
sl@0
    37
#   include <boost/mpl/limits/arity.hpp>
sl@0
    38
#   include <boost/mpl/aux_/preprocessor/params.hpp>
sl@0
    39
#   include <boost/mpl/aux_/preprocessor/default_params.hpp>
sl@0
    40
#   include <boost/mpl/aux_/preprocessor/enum.hpp>
sl@0
    41
#   include <boost/mpl/aux_/config/ctps.hpp>
sl@0
    42
#   include <boost/mpl/aux_/config/dtp.hpp>
sl@0
    43
sl@0
    44
#   include <boost/preprocessor/iterate.hpp>
sl@0
    45
#   include <boost/preprocessor/dec.hpp>
sl@0
    46
#   include <boost/preprocessor/cat.hpp>
sl@0
    47
sl@0
    48
namespace boost { namespace mpl {
sl@0
    49
sl@0
    50
// 'inherit<T1,T2,..,Tn>' metafunction; returns an unspecified class type
sl@0
    51
// produced by public derivation from all metafunction's parameters 
sl@0
    52
// (T1,T2,..,Tn), except the parameters of 'empty_base' class type; 
sl@0
    53
// regardless the position and number of 'empty_base' parameters in the 
sl@0
    54
// metafunction's argument list, derivation from them is always a no-op;
sl@0
    55
// for instance:
sl@0
    56
//      inherit<her>::type == her
sl@0
    57
//      inherit<her,my>::type == struct unspecified : her, my {};
sl@0
    58
//      inherit<empty_base,her>::type == her
sl@0
    59
//      inherit<empty_base,her,empty_base,empty_base>::type == her
sl@0
    60
//      inherit<her,empty_base,my>::type == struct unspecified : her, my {};
sl@0
    61
//      inherit<empty_base,empty_base>::type == empty_base
sl@0
    62
sl@0
    63
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
sl@0
    64
sl@0
    65
template< 
sl@0
    66
      typename BOOST_MPL_AUX_NA_PARAM(T1)
sl@0
    67
    , typename BOOST_MPL_AUX_NA_PARAM(T2)
sl@0
    68
    > 
sl@0
    69
struct inherit2
sl@0
    70
    : T1, T2
sl@0
    71
{
sl@0
    72
    typedef inherit2 type;
sl@0
    73
    BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2))
sl@0
    74
};
sl@0
    75
sl@0
    76
template< typename T1 > 
sl@0
    77
struct inherit2<T1,empty_base>
sl@0
    78
{
sl@0
    79
    typedef T1 type;
sl@0
    80
    BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (T1,empty_base))
sl@0
    81
};
sl@0
    82
sl@0
    83
template< typename T2 > 
sl@0
    84
struct inherit2<empty_base,T2>
sl@0
    85
{
sl@0
    86
    typedef T2 type;
sl@0
    87
    BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,T2))
sl@0
    88
};
sl@0
    89
sl@0
    90
// needed to disambiguate the previous two in case when both 
sl@0
    91
// T1 and T2 == empty_base
sl@0
    92
template<> 
sl@0
    93
struct inherit2<empty_base,empty_base>
sl@0
    94
{
sl@0
    95
    typedef empty_base type;
sl@0
    96
    BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,empty_base))
sl@0
    97
};
sl@0
    98
sl@0
    99
#else
sl@0
   100
sl@0
   101
namespace aux {
sl@0
   102
sl@0
   103
template< bool C1, bool C2 >
sl@0
   104
struct inherit2_impl
sl@0
   105
{
sl@0
   106
    template< typename Derived, typename T1, typename T2 > struct result_ 
sl@0
   107
        : T1, T2
sl@0
   108
    {
sl@0
   109
        typedef Derived type_;
sl@0
   110
    };
sl@0
   111
};
sl@0
   112
sl@0
   113
template<>
sl@0
   114
struct inherit2_impl<false,true>
sl@0
   115
{
sl@0
   116
    template< typename Derived, typename T1, typename T2 > struct result_
sl@0
   117
        : T1
sl@0
   118
    {
sl@0
   119
        typedef T1 type_;
sl@0
   120
    };
sl@0
   121
};
sl@0
   122
sl@0
   123
template<>
sl@0
   124
struct inherit2_impl<true,false>
sl@0
   125
{
sl@0
   126
    template< typename Derived, typename T1, typename T2 > struct result_
sl@0
   127
        : T2 
sl@0
   128
    {
sl@0
   129
        typedef T2 type_;
sl@0
   130
    };
sl@0
   131
};
sl@0
   132
sl@0
   133
template<>
sl@0
   134
struct inherit2_impl<true,true>
sl@0
   135
{
sl@0
   136
    template< typename Derived, typename T1, typename T2 > struct result_
sl@0
   137
    {
sl@0
   138
        typedef T1 type_;
sl@0
   139
    };
sl@0
   140
};
sl@0
   141
sl@0
   142
} // namespace aux
sl@0
   143
sl@0
   144
template< 
sl@0
   145
      typename BOOST_MPL_AUX_NA_PARAM(T1)
sl@0
   146
    , typename BOOST_MPL_AUX_NA_PARAM(T2)
sl@0
   147
    > 
sl@0
   148
struct inherit2
sl@0
   149
    : aux::inherit2_impl<
sl@0
   150
          is_empty_base<T1>::value
sl@0
   151
        , is_empty_base<T2>::value
sl@0
   152
        >::template result_< inherit2<T1,T2>,T1,T2 >
sl@0
   153
{
sl@0
   154
    typedef typename inherit2::type_ type;
sl@0
   155
    BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2))
sl@0
   156
};
sl@0
   157
sl@0
   158
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
   159
sl@0
   160
BOOST_MPL_AUX_NA_SPEC(2, inherit2)
sl@0
   161
sl@0
   162
#define BOOST_PP_ITERATION_PARAMS_1 \
sl@0
   163
    (3,(3, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/inherit.hpp>))
sl@0
   164
#include BOOST_PP_ITERATE()
sl@0
   165
sl@0
   166
}}
sl@0
   167
sl@0
   168
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
sl@0
   169
#endif // BOOST_MPL_INHERIT_HPP_INCLUDED
sl@0
   170
sl@0
   171
///// iteration
sl@0
   172
sl@0
   173
#else
sl@0
   174
#define n_ BOOST_PP_FRAME_ITERATION(1)
sl@0
   175
sl@0
   176
template<
sl@0
   177
      BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, na)
sl@0
   178
    >
sl@0
   179
struct BOOST_PP_CAT(inherit,n_)
sl@0
   180
    : inherit2<
sl@0
   181
          typename BOOST_PP_CAT(inherit,BOOST_PP_DEC(n_))<
sl@0
   182
              BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(n_), T)
sl@0
   183
            >::type
sl@0
   184
        , BOOST_PP_CAT(T,n_)
sl@0
   185
        >
sl@0
   186
{
sl@0
   187
    BOOST_MPL_AUX_LAMBDA_SUPPORT(
sl@0
   188
          n_
sl@0
   189
        , BOOST_PP_CAT(inherit,n_)
sl@0
   190
        , (BOOST_MPL_PP_PARAMS(n_, T))
sl@0
   191
        )
sl@0
   192
};
sl@0
   193
sl@0
   194
BOOST_MPL_AUX_NA_SPEC(n_, BOOST_PP_CAT(inherit,n_))
sl@0
   195
sl@0
   196
#if n_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
sl@0
   197
/// primary template
sl@0
   198
template<
sl@0
   199
      BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base)
sl@0
   200
    >
sl@0
   201
struct inherit
sl@0
   202
    : BOOST_PP_CAT(inherit,n_)<BOOST_MPL_PP_PARAMS(n_, T)>
sl@0
   203
{
sl@0
   204
};
sl@0
   205
sl@0
   206
// 'na' specialization
sl@0
   207
template<>
sl@0
   208
struct inherit< BOOST_MPL_PP_ENUM(5, na) >
sl@0
   209
{
sl@0
   210
    template<
sl@0
   211
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
sl@0
   212
          BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base)
sl@0
   213
#else
sl@0
   214
          BOOST_MPL_PP_PARAMS(n_, typename T)
sl@0
   215
#endif
sl@0
   216
        >
sl@0
   217
    struct apply
sl@0
   218
        : inherit< BOOST_MPL_PP_PARAMS(n_, T) >
sl@0
   219
    {
sl@0
   220
    };
sl@0
   221
};
sl@0
   222
sl@0
   223
BOOST_MPL_AUX_NA_SPEC_LAMBDA(n_, inherit)
sl@0
   224
BOOST_MPL_AUX_NA_SPEC_ARITY(n_, inherit)
sl@0
   225
BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(n_, n_, inherit)
sl@0
   226
#endif
sl@0
   227
sl@0
   228
#undef n_
sl@0
   229
#endif // BOOST_PP_IS_ITERATING