epoc32/include/stdapis/boost/detail/indirect_traits.hpp
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright David Abrahams 2002.
williamr@2
     2
// Distributed under the Boost Software License, Version 1.0. (See
williamr@2
     3
// accompanying file LICENSE_1_0.txt or copy at
williamr@2
     4
// http://www.boost.org/LICENSE_1_0.txt)
williamr@2
     5
#ifndef INDIRECT_TRAITS_DWA2002131_HPP
williamr@2
     6
# define INDIRECT_TRAITS_DWA2002131_HPP
williamr@2
     7
# include <boost/type_traits/is_function.hpp>
williamr@2
     8
# include <boost/type_traits/is_reference.hpp>
williamr@2
     9
# include <boost/type_traits/is_pointer.hpp>
williamr@2
    10
# include <boost/type_traits/is_class.hpp>
williamr@2
    11
# include <boost/type_traits/is_const.hpp>
williamr@2
    12
# include <boost/type_traits/is_volatile.hpp>
williamr@2
    13
# include <boost/type_traits/is_member_function_pointer.hpp>
williamr@2
    14
# include <boost/type_traits/is_member_pointer.hpp>
williamr@2
    15
# include <boost/type_traits/remove_cv.hpp>
williamr@2
    16
# include <boost/type_traits/remove_reference.hpp>
williamr@2
    17
# include <boost/type_traits/remove_pointer.hpp>
williamr@2
    18
williamr@2
    19
# include <boost/type_traits/detail/ice_and.hpp>
williamr@2
    20
# include <boost/detail/workaround.hpp>
williamr@2
    21
williamr@2
    22
# include <boost/mpl/eval_if.hpp>
williamr@2
    23
# include <boost/mpl/if.hpp>
williamr@2
    24
# include <boost/mpl/bool.hpp>
williamr@2
    25
# include <boost/mpl/and.hpp>
williamr@2
    26
# include <boost/mpl/not.hpp>
williamr@2
    27
# include <boost/mpl/aux_/lambda_support.hpp>
williamr@2
    28
williamr@2
    29
#  ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    30
#   include <boost/detail/is_function_ref_tester.hpp>
williamr@2
    31
#  endif 
williamr@2
    32
williamr@2
    33
namespace boost { namespace detail {
williamr@2
    34
williamr@2
    35
namespace indirect_traits {
williamr@2
    36
williamr@2
    37
#  ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
williamr@2
    38
template <class T>
williamr@2
    39
struct is_reference_to_const : mpl::false_
williamr@2
    40
{
williamr@2
    41
};
williamr@2
    42
williamr@2
    43
template <class T>
williamr@2
    44
struct is_reference_to_const<T const&> : mpl::true_
williamr@2
    45
{
williamr@2
    46
};
williamr@2
    47
williamr@2
    48
#   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
williamr@2
    49
template<class T>
williamr@2
    50
struct is_reference_to_const<T const volatile&> : mpl::true_
williamr@2
    51
{
williamr@2
    52
};
williamr@2
    53
#   endif 
williamr@2
    54
williamr@2
    55
template <class T>
williamr@2
    56
struct is_reference_to_function : mpl::false_
williamr@2
    57
{
williamr@2
    58
};
williamr@2
    59
williamr@2
    60
template <class T>
williamr@2
    61
struct is_reference_to_function<T&> : is_function<T>
williamr@2
    62
{
williamr@2
    63
};
williamr@2
    64
williamr@2
    65
template <class T>
williamr@2
    66
struct is_pointer_to_function : mpl::false_
williamr@2
    67
{
williamr@2
    68
};
williamr@2
    69
williamr@2
    70
// There's no such thing as a pointer-to-cv-function, so we don't need
williamr@2
    71
// specializations for those
williamr@2
    72
template <class T>
williamr@2
    73
struct is_pointer_to_function<T*> : is_function<T>
williamr@2
    74
{
williamr@2
    75
};
williamr@2
    76
williamr@2
    77
template <class T>
williamr@2
    78
struct is_reference_to_member_function_pointer_impl : mpl::false_
williamr@2
    79
{
williamr@2
    80
};
williamr@2
    81
williamr@2
    82
template <class T>
williamr@2
    83
struct is_reference_to_member_function_pointer_impl<T&>
williamr@2
    84
    : is_member_function_pointer<typename remove_cv<T>::type>
williamr@2
    85
{
williamr@2
    86
};
williamr@2
    87
williamr@2
    88
williamr@2
    89
template <class T>
williamr@2
    90
struct is_reference_to_member_function_pointer
williamr@2
    91
    : is_reference_to_member_function_pointer_impl<T>
williamr@2
    92
{
williamr@2
    93
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))
williamr@2
    94
};
williamr@2
    95
williamr@2
    96
template <class T>
williamr@2
    97
struct is_reference_to_function_pointer_aux
williamr@2
    98
    : mpl::and_<
williamr@2
    99
          is_reference<T>
williamr@2
   100
        , is_pointer_to_function<
williamr@2
   101
              typename remove_cv<
williamr@2
   102
                  typename remove_reference<T>::type
williamr@2
   103
              >::type
williamr@2
   104
          >
williamr@2
   105
      >
williamr@2
   106
{
williamr@2
   107
    // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
williamr@2
   108
};
williamr@2
   109
williamr@2
   110
template <class T>
williamr@2
   111
struct is_reference_to_function_pointer
williamr@2
   112
    : mpl::if_<
williamr@2
   113
          is_reference_to_function<T>
williamr@2
   114
        , mpl::false_
williamr@2
   115
        , is_reference_to_function_pointer_aux<T>
williamr@2
   116
     >::type
williamr@2
   117
{
williamr@2
   118
};
williamr@2
   119
williamr@2
   120
template <class T>
williamr@2
   121
struct is_reference_to_non_const
williamr@2
   122
    : mpl::and_<
williamr@2
   123
          is_reference<T>
williamr@2
   124
        , mpl::not_<
williamr@2
   125
             is_reference_to_const<T>
williamr@2
   126
          >
williamr@2
   127
      >
williamr@2
   128
{
williamr@2
   129
};
williamr@2
   130
williamr@2
   131
template <class T>
williamr@2
   132
struct is_reference_to_volatile : mpl::false_
williamr@2
   133
{
williamr@2
   134
};
williamr@2
   135
williamr@2
   136
template <class T>
williamr@2
   137
struct is_reference_to_volatile<T volatile&> : mpl::true_
williamr@2
   138
{
williamr@2
   139
};
williamr@2
   140
williamr@2
   141
#   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
williamr@2
   142
template <class T>
williamr@2
   143
struct is_reference_to_volatile<T const volatile&> : mpl::true_
williamr@2
   144
{
williamr@2
   145
};
williamr@2
   146
#   endif 
williamr@2
   147
williamr@2
   148
williamr@2
   149
template <class T>
williamr@2
   150
struct is_reference_to_pointer : mpl::false_
williamr@2
   151
{
williamr@2
   152
};
williamr@2
   153
williamr@2
   154
template <class T>
williamr@2
   155
struct is_reference_to_pointer<T*&> : mpl::true_
williamr@2
   156
{
williamr@2
   157
};
williamr@2
   158
williamr@2
   159
template <class T>
williamr@2
   160
struct is_reference_to_pointer<T* const&> : mpl::true_
williamr@2
   161
{
williamr@2
   162
};
williamr@2
   163
williamr@2
   164
template <class T>
williamr@2
   165
struct is_reference_to_pointer<T* volatile&> : mpl::true_
williamr@2
   166
{
williamr@2
   167
};
williamr@2
   168
williamr@2
   169
template <class T>
williamr@2
   170
struct is_reference_to_pointer<T* const volatile&> : mpl::true_
williamr@2
   171
{
williamr@2
   172
};
williamr@2
   173
williamr@2
   174
template <class T>
williamr@2
   175
struct is_reference_to_class
williamr@2
   176
    : mpl::and_<
williamr@2
   177
          is_reference<T>
williamr@2
   178
        , is_class<
williamr@2
   179
              typename remove_cv<
williamr@2
   180
                  typename remove_reference<T>::type
williamr@2
   181
              >::type
williamr@2
   182
          >
williamr@2
   183
      >
williamr@2
   184
{
williamr@2
   185
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))
williamr@2
   186
};
williamr@2
   187
williamr@2
   188
template <class T>
williamr@2
   189
struct is_pointer_to_class
williamr@2
   190
    : mpl::and_<
williamr@2
   191
          is_pointer<T>
williamr@2
   192
        , is_class<
williamr@2
   193
              typename remove_cv<
williamr@2
   194
                  typename remove_pointer<T>::type
williamr@2
   195
              >::type
williamr@2
   196
          >
williamr@2
   197
      >
williamr@2
   198
{
williamr@2
   199
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T))
williamr@2
   200
};
williamr@2
   201
williamr@2
   202
#  else
williamr@2
   203
williamr@2
   204
using namespace boost::detail::is_function_ref_tester_;
williamr@2
   205
williamr@2
   206
typedef char (&inner_yes_type)[3];
williamr@2
   207
typedef char (&inner_no_type)[2];
williamr@2
   208
typedef char (&outer_no_type)[1];
williamr@2
   209
williamr@2
   210
template <typename V>
williamr@2
   211
struct is_const_help
williamr@2
   212
{
williamr@2
   213
    typedef typename mpl::if_<
williamr@2
   214
          is_const<V>
williamr@2
   215
        , inner_yes_type
williamr@2
   216
        , inner_no_type
williamr@2
   217
        >::type type;
williamr@2
   218
};
williamr@2
   219
williamr@2
   220
template <typename V>
williamr@2
   221
struct is_volatile_help
williamr@2
   222
{
williamr@2
   223
    typedef typename mpl::if_<
williamr@2
   224
          is_volatile<V>
williamr@2
   225
        , inner_yes_type
williamr@2
   226
        , inner_no_type
williamr@2
   227
        >::type type;
williamr@2
   228
};
williamr@2
   229
williamr@2
   230
template <typename V>
williamr@2
   231
struct is_pointer_help
williamr@2
   232
{
williamr@2
   233
    typedef typename mpl::if_<
williamr@2
   234
          is_pointer<V>
williamr@2
   235
        , inner_yes_type
williamr@2
   236
        , inner_no_type
williamr@2
   237
        >::type type;
williamr@2
   238
};
williamr@2
   239
williamr@2
   240
template <typename V>
williamr@2
   241
struct is_class_help
williamr@2
   242
{
williamr@2
   243
    typedef typename mpl::if_<
williamr@2
   244
          is_class<V>
williamr@2
   245
        , inner_yes_type
williamr@2
   246
        , inner_no_type
williamr@2
   247
        >::type type;
williamr@2
   248
};
williamr@2
   249
williamr@2
   250
template <class T>
williamr@2
   251
struct is_reference_to_function_aux
williamr@2
   252
{
williamr@2
   253
    static T t;
williamr@2
   254
    BOOST_STATIC_CONSTANT(
williamr@2
   255
        bool, value = sizeof(detail::is_function_ref_tester(t,0)) == sizeof(::boost::type_traits::yes_type));
williamr@2
   256
    typedef mpl::bool_<value> type;
williamr@2
   257
 };
williamr@2
   258
williamr@2
   259
template <class T>
williamr@2
   260
struct is_reference_to_function
williamr@2
   261
    : mpl::if_<is_reference<T>, is_reference_to_function_aux<T>, mpl::bool_<false> >::type
williamr@2
   262
{
williamr@2
   263
};
williamr@2
   264
williamr@2
   265
template <class T>
williamr@2
   266
struct is_pointer_to_function_aux
williamr@2
   267
{
williamr@2
   268
    static T t;
williamr@2
   269
    BOOST_STATIC_CONSTANT(
williamr@2
   270
        bool, value
williamr@2
   271
        = sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type));
williamr@2
   272
    typedef mpl::bool_<value> type;
williamr@2
   273
};
williamr@2
   274
williamr@2
   275
template <class T>
williamr@2
   276
struct is_pointer_to_function
williamr@2
   277
    : mpl::if_<is_pointer<T>, is_pointer_to_function_aux<T>, mpl::bool_<false> >::type
williamr@2
   278
{
williamr@2
   279
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_function,(T))
williamr@2
   280
};
williamr@2
   281
williamr@2
   282
struct false_helper1
williamr@2
   283
{
williamr@2
   284
    template <class T>
williamr@2
   285
    struct apply : mpl::false_
williamr@2
   286
    {
williamr@2
   287
    };
williamr@2
   288
};
williamr@2
   289
williamr@2
   290
template <typename V>
williamr@2
   291
typename is_const_help<V>::type reference_to_const_helper(V&);    
williamr@2
   292
outer_no_type
williamr@2
   293
reference_to_const_helper(...);
williamr@2
   294
williamr@2
   295
struct true_helper1
williamr@2
   296
{
williamr@2
   297
    template <class T>
williamr@2
   298
    struct apply
williamr@2
   299
    {
williamr@2
   300
        static T t;
williamr@2
   301
        BOOST_STATIC_CONSTANT(
williamr@2
   302
            bool, value
williamr@2
   303
            = sizeof(reference_to_const_helper(t)) == sizeof(inner_yes_type));
williamr@2
   304
        typedef mpl::bool_<value> type;
williamr@2
   305
    };
williamr@2
   306
};
williamr@2
   307
williamr@2
   308
template <bool ref = true>
williamr@2
   309
struct is_reference_to_const_helper1 : true_helper1
williamr@2
   310
{
williamr@2
   311
};
williamr@2
   312
williamr@2
   313
template <>
williamr@2
   314
struct is_reference_to_const_helper1<false> : false_helper1
williamr@2
   315
{
williamr@2
   316
};
williamr@2
   317
williamr@2
   318
williamr@2
   319
template <class T>
williamr@2
   320
struct is_reference_to_const
williamr@2
   321
    : is_reference_to_const_helper1<is_reference<T>::value>::template apply<T>
williamr@2
   322
{
williamr@2
   323
};
williamr@2
   324
williamr@2
   325
williamr@2
   326
template <bool ref = true>
williamr@2
   327
struct is_reference_to_non_const_helper1
williamr@2
   328
{
williamr@2
   329
    template <class T>
williamr@2
   330
    struct apply
williamr@2
   331
    {
williamr@2
   332
        static T t;
williamr@2
   333
        BOOST_STATIC_CONSTANT(
williamr@2
   334
            bool, value
williamr@2
   335
            = sizeof(reference_to_const_helper(t)) == sizeof(inner_no_type));
williamr@2
   336
        
williamr@2
   337
        typedef mpl::bool_<value> type;
williamr@2
   338
    };
williamr@2
   339
};
williamr@2
   340
williamr@2
   341
template <>
williamr@2
   342
struct is_reference_to_non_const_helper1<false> : false_helper1
williamr@2
   343
{
williamr@2
   344
};
williamr@2
   345
williamr@2
   346
williamr@2
   347
template <class T>
williamr@2
   348
struct is_reference_to_non_const
williamr@2
   349
    : is_reference_to_non_const_helper1<is_reference<T>::value>::template apply<T>
williamr@2
   350
{
williamr@2
   351
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_non_const,(T))
williamr@2
   352
};
williamr@2
   353
williamr@2
   354
williamr@2
   355
template <typename V>
williamr@2
   356
typename is_volatile_help<V>::type reference_to_volatile_helper(V&);    
williamr@2
   357
outer_no_type
williamr@2
   358
reference_to_volatile_helper(...);
williamr@2
   359
williamr@2
   360
template <bool ref = true>
williamr@2
   361
struct is_reference_to_volatile_helper1
williamr@2
   362
{
williamr@2
   363
    template <class T>
williamr@2
   364
    struct apply
williamr@2
   365
    {
williamr@2
   366
        static T t;
williamr@2
   367
        BOOST_STATIC_CONSTANT(
williamr@2
   368
            bool, value
williamr@2
   369
            = sizeof(reference_to_volatile_helper(t)) == sizeof(inner_yes_type));
williamr@2
   370
        typedef mpl::bool_<value> type;
williamr@2
   371
    };
williamr@2
   372
};
williamr@2
   373
williamr@2
   374
template <>
williamr@2
   375
struct is_reference_to_volatile_helper1<false> : false_helper1
williamr@2
   376
{
williamr@2
   377
};
williamr@2
   378
williamr@2
   379
williamr@2
   380
template <class T>
williamr@2
   381
struct is_reference_to_volatile
williamr@2
   382
    : is_reference_to_volatile_helper1<is_reference<T>::value>::template apply<T>
williamr@2
   383
{
williamr@2
   384
};
williamr@2
   385
williamr@2
   386
template <typename V>
williamr@2
   387
typename is_pointer_help<V>::type reference_to_pointer_helper(V&);
williamr@2
   388
outer_no_type reference_to_pointer_helper(...);
williamr@2
   389
williamr@2
   390
template <class T>
williamr@2
   391
struct reference_to_pointer_impl
williamr@2
   392
{
williamr@2
   393
    static T t;
williamr@2
   394
    BOOST_STATIC_CONSTANT(
williamr@2
   395
        bool, value
williamr@2
   396
        = (sizeof((reference_to_pointer_helper)(t)) == sizeof(inner_yes_type))
williamr@2
   397
        );
williamr@2
   398
    
williamr@2
   399
    typedef mpl::bool_<value> type;
williamr@2
   400
};
williamr@2
   401
   
williamr@2
   402
template <class T>
williamr@2
   403
struct is_reference_to_pointer
williamr@2
   404
  : mpl::eval_if<is_reference<T>, reference_to_pointer_impl<T>, mpl::false_>::type
williamr@2
   405
{   
williamr@2
   406
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_pointer,(T))
williamr@2
   407
};
williamr@2
   408
williamr@2
   409
template <class T>
williamr@2
   410
struct is_reference_to_function_pointer
williamr@2
   411
  : mpl::eval_if<is_reference<T>, is_pointer_to_function_aux<T>, mpl::false_>::type
williamr@2
   412
{
williamr@2
   413
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_function_pointer,(T))
williamr@2
   414
};
williamr@2
   415
williamr@2
   416
williamr@2
   417
template <class T>
williamr@2
   418
struct is_member_function_pointer_help
williamr@2
   419
    : mpl::if_<is_member_function_pointer<T>, inner_yes_type, inner_no_type>
williamr@2
   420
{};
williamr@2
   421
williamr@2
   422
template <typename V>
williamr@2
   423
typename is_member_function_pointer_help<V>::type member_function_pointer_helper(V&);
williamr@2
   424
outer_no_type member_function_pointer_helper(...);
williamr@2
   425
williamr@2
   426
template <class T>
williamr@2
   427
struct is_pointer_to_member_function_aux
williamr@2
   428
{
williamr@2
   429
    static T t;
williamr@2
   430
    BOOST_STATIC_CONSTANT(
williamr@2
   431
        bool, value
williamr@2
   432
        = sizeof((member_function_pointer_helper)(t)) == sizeof(inner_yes_type));
williamr@2
   433
    typedef mpl::bool_<value> type;
williamr@2
   434
};
williamr@2
   435
williamr@2
   436
template <class T>
williamr@2
   437
struct is_reference_to_member_function_pointer
williamr@2
   438
    : mpl::if_<
williamr@2
   439
        is_reference<T>
williamr@2
   440
        , is_pointer_to_member_function_aux<T>
williamr@2
   441
        , mpl::bool_<false>
williamr@2
   442
     >::type
williamr@2
   443
{
williamr@2
   444
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))
williamr@2
   445
};
williamr@2
   446
williamr@2
   447
template <typename V>
williamr@2
   448
typename is_class_help<V>::type reference_to_class_helper(V const volatile&);
williamr@2
   449
outer_no_type reference_to_class_helper(...);
williamr@2
   450
williamr@2
   451
template <class T>
williamr@2
   452
struct is_reference_to_class
williamr@2
   453
{
williamr@2
   454
    static T t;
williamr@2
   455
    BOOST_STATIC_CONSTANT(
williamr@2
   456
        bool, value
williamr@2
   457
        = (is_reference<T>::value
williamr@2
   458
           & (sizeof(reference_to_class_helper(t)) == sizeof(inner_yes_type)))
williamr@2
   459
        );
williamr@2
   460
    typedef mpl::bool_<value> type;
williamr@2
   461
    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))
williamr@2
   462
};
williamr@2
   463
williamr@2
   464
template <typename V>
williamr@2
   465
typename is_class_help<V>::type pointer_to_class_helper(V const volatile*);
williamr@2
   466
outer_no_type pointer_to_class_helper(...);
williamr@2
   467
williamr@2
   468
template <class T>
williamr@2
   469
struct is_pointer_to_class
williamr@2
   470
{
williamr@2
   471
    static T t;
williamr@2
   472
    BOOST_STATIC_CONSTANT(
williamr@2
   473
        bool, value
williamr@2
   474
        = (is_pointer<T>::value
williamr@2
   475
           && sizeof(pointer_to_class_helper(t)) == sizeof(inner_yes_type))
williamr@2
   476
        );
williamr@2
   477
    typedef mpl::bool_<value> type;
williamr@2
   478
};
williamr@2
   479
#  endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 
williamr@2
   480
williamr@2
   481
}
williamr@2
   482
williamr@2
   483
using namespace indirect_traits;
williamr@2
   484
williamr@2
   485
}} // namespace boost::python::detail
williamr@2
   486
williamr@2
   487
#endif // INDIRECT_TRAITS_DWA2002131_HPP