epoc32/include/stdapis/boost/mpl/if.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
williamr@4
     2
#ifndef BOOST_MPL_IF_HPP_INCLUDED
williamr@4
     3
#define BOOST_MPL_IF_HPP_INCLUDED
williamr@4
     4
williamr@4
     5
// Copyright Aleksey Gurtovoy 2000-2004
williamr@4
     6
//
williamr@4
     7
// Distributed under the Boost Software License, Version 1.0. 
williamr@4
     8
// (See accompanying file LICENSE_1_0.txt or copy at 
williamr@4
     9
// http://www.boost.org/LICENSE_1_0.txt)
williamr@4
    10
//
williamr@4
    11
// See http://www.boost.org/libs/mpl for documentation.
williamr@4
    12
williamr@4
    13
// $Source: /cvsroot/boost/boost/boost/mpl/if.hpp,v $
williamr@4
    14
// $Date: 2004/09/07 08:51:31 $
williamr@4
    15
// $Revision: 1.25 $
williamr@4
    16
williamr@4
    17
#include <boost/mpl/aux_/value_wknd.hpp>
williamr@4
    18
#include <boost/mpl/aux_/static_cast.hpp>
williamr@4
    19
#include <boost/mpl/aux_/na_spec.hpp>
williamr@4
    20
#include <boost/mpl/aux_/lambda_support.hpp>
williamr@4
    21
#include <boost/mpl/aux_/config/integral.hpp>
williamr@4
    22
#include <boost/mpl/aux_/config/ctps.hpp>
williamr@4
    23
#include <boost/mpl/aux_/config/workaround.hpp>
williamr@4
    24
williamr@4
    25
namespace boost { namespace mpl {
williamr@4
    26
williamr@4
    27
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
williamr@4
    28
williamr@4
    29
template<
williamr@4
    30
      bool C
williamr@4
    31
    , typename T1
williamr@4
    32
    , typename T2
williamr@4
    33
    >
williamr@4
    34
struct if_c
williamr@4
    35
{
williamr@4
    36
    typedef T1 type;
williamr@4
    37
};
williamr@4
    38
williamr@4
    39
template<
williamr@4
    40
      typename T1
williamr@4
    41
    , typename T2
williamr@4
    42
    >
williamr@4
    43
struct if_c<false,T1,T2>
williamr@4
    44
{
williamr@4
    45
    typedef T2 type;
williamr@4
    46
};
williamr@4
    47
williamr@4
    48
// agurt, 05/sep/04: nondescriptive parameter names for the sake of DigitalMars
williamr@4
    49
// (and possibly MWCW < 8.0); see http://article.gmane.org/gmane.comp.lib.boost.devel/108959
williamr@4
    50
template<
williamr@4
    51
      typename BOOST_MPL_AUX_NA_PARAM(T1)
williamr@4
    52
    , typename BOOST_MPL_AUX_NA_PARAM(T2)
williamr@4
    53
    , typename BOOST_MPL_AUX_NA_PARAM(T3)
williamr@4
    54
    >
williamr@4
    55
struct if_
williamr@4
    56
{
williamr@4
    57
 private:
williamr@4
    58
    // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC 
williamr@4
    59
    typedef if_c<
williamr@4
    60
#if defined(BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS)
williamr@4
    61
          BOOST_MPL_AUX_VALUE_WKND(T1)::value
williamr@4
    62
#else
williamr@4
    63
          BOOST_MPL_AUX_STATIC_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(T1)::value)
williamr@4
    64
#endif
williamr@4
    65
        , T2
williamr@4
    66
        , T3
williamr@4
    67
        > almost_type_;
williamr@4
    68
 
williamr@4
    69
 public:
williamr@4
    70
    typedef typename almost_type_::type type;
williamr@4
    71
    
williamr@4
    72
    BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(T1,T2,T3))
williamr@4
    73
};
williamr@4
    74
williamr@4
    75
#else
williamr@4
    76
williamr@4
    77
// no partial class template specialization
williamr@4
    78
williamr@4
    79
namespace aux {
williamr@4
    80
williamr@4
    81
template< bool C >
williamr@4
    82
struct if_impl
williamr@4
    83
{
williamr@4
    84
    template< typename T1, typename T2 > struct result_
williamr@4
    85
    {
williamr@4
    86
        typedef T1 type;
williamr@4
    87
    };
williamr@4
    88
};
williamr@4
    89
williamr@4
    90
template<>
williamr@4
    91
struct if_impl<false>
williamr@4
    92
{
williamr@4
    93
    template< typename T1, typename T2 > struct result_
williamr@4
    94
    { 
williamr@4
    95
        typedef T2 type;
williamr@4
    96
    };
williamr@4
    97
};
williamr@4
    98
williamr@4
    99
} // namespace aux
williamr@4
   100
williamr@4
   101
template<
williamr@4
   102
      bool C_
williamr@4
   103
    , typename T1
williamr@4
   104
    , typename T2
williamr@4
   105
    >
williamr@4
   106
struct if_c
williamr@4
   107
{
williamr@4
   108
    typedef typename aux::if_impl< C_ >
williamr@4
   109
        ::template result_<T1,T2>::type type;
williamr@4
   110
};
williamr@4
   111
williamr@4
   112
// (almost) copy & paste in order to save one more 
williamr@4
   113
// recursively nested template instantiation to user
williamr@4
   114
template<
williamr@4
   115
      typename BOOST_MPL_AUX_NA_PARAM(C_)
williamr@4
   116
    , typename BOOST_MPL_AUX_NA_PARAM(T1)
williamr@4
   117
    , typename BOOST_MPL_AUX_NA_PARAM(T2)
williamr@4
   118
    >
williamr@4
   119
struct if_
williamr@4
   120
{
williamr@4
   121
    enum { msvc_wknd_ = BOOST_MPL_AUX_MSVC_VALUE_WKND(C_)::value };
williamr@4
   122
williamr@4
   123
    typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc_wknd_) >
williamr@4
   124
        ::template result_<T1,T2>::type type;
williamr@4
   125
williamr@4
   126
    BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2))
williamr@4
   127
};
williamr@4
   128
williamr@4
   129
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@4
   130
williamr@4
   131
BOOST_MPL_AUX_NA_SPEC(3, if_)
williamr@4
   132
williamr@4
   133
}}
williamr@4
   134
williamr@4
   135
#endif // BOOST_MPL_IF_HPP_INCLUDED