epoc32/include/stdapis/boost/lambda/detail/member_ptr.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// Boost Lambda Library -- member_ptr.hpp ---------------------
williamr@2
     2
williamr@2
     3
// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
williamr@2
     4
// Copyright (C) 2000 Gary Powell (gary.powell@sierra.com)
williamr@2
     5
//
williamr@2
     6
// Distributed under the Boost Software License, Version 1.0. (See
williamr@2
     7
// accompanying file LICENSE_1_0.txt or copy at
williamr@2
     8
// http://www.boost.org/LICENSE_1_0.txt)
williamr@2
     9
//
williamr@2
    10
// For more information, see www.boost.org
williamr@2
    11
williamr@2
    12
// --------------------------------------------------------------------------
williamr@2
    13
williamr@2
    14
#if !defined(BOOST_LAMBDA_MEMBER_PTR_HPP)
williamr@2
    15
#define BOOST_LAMBDA_MEMBER_PTR_HPP
williamr@2
    16
williamr@2
    17
namespace boost { 
williamr@2
    18
namespace lambda {
williamr@2
    19
williamr@2
    20
williamr@2
    21
class member_pointer_action {};
williamr@2
    22
williamr@2
    23
williamr@2
    24
namespace detail {
williamr@2
    25
williamr@2
    26
// the boost type_traits member_pointer traits are not enough, 
williamr@2
    27
// need to know more details.
williamr@2
    28
template<class T>
williamr@2
    29
struct member_pointer {
williamr@2
    30
  typedef typename boost::add_reference<T>::type type;
williamr@2
    31
  typedef detail::unspecified class_type;
williamr@2
    32
  typedef detail::unspecified qualified_class_type;
williamr@2
    33
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
    34
  BOOST_STATIC_CONSTANT(bool, is_function_member = false);
williamr@2
    35
};
williamr@2
    36
williamr@2
    37
template<class T, class U>
williamr@2
    38
struct member_pointer<T U::*> {
williamr@2
    39
  typedef typename boost::add_reference<T>::type type;
williamr@2
    40
  typedef U class_type;
williamr@2
    41
  typedef U qualified_class_type;
williamr@2
    42
  BOOST_STATIC_CONSTANT(bool, is_data_member = true);
williamr@2
    43
  BOOST_STATIC_CONSTANT(bool, is_function_member = false);
williamr@2
    44
};
williamr@2
    45
williamr@2
    46
template<class T, class U>
williamr@2
    47
struct member_pointer<const T U::*> {
williamr@2
    48
  typedef typename boost::add_reference<const T>::type type;
williamr@2
    49
  typedef U class_type;
williamr@2
    50
  typedef const U qualified_class_type;
williamr@2
    51
  BOOST_STATIC_CONSTANT(bool, is_data_member = true);
williamr@2
    52
  BOOST_STATIC_CONSTANT(bool, is_function_member = false);
williamr@2
    53
};
williamr@2
    54
williamr@2
    55
template<class T, class U>
williamr@2
    56
struct member_pointer<volatile T U::*> {
williamr@2
    57
  typedef typename boost::add_reference<volatile T>::type type;
williamr@2
    58
  typedef U class_type;
williamr@2
    59
  typedef volatile U qualified_class_type;
williamr@2
    60
  BOOST_STATIC_CONSTANT(bool, is_data_member = true);
williamr@2
    61
  BOOST_STATIC_CONSTANT(bool, is_function_member = false);
williamr@2
    62
};
williamr@2
    63
williamr@2
    64
template<class T, class U>
williamr@2
    65
struct member_pointer<const volatile T U::*> {
williamr@2
    66
  typedef typename boost::add_reference<const volatile T>::type type;
williamr@2
    67
  typedef U class_type;
williamr@2
    68
  typedef const volatile U qualified_class_type;
williamr@2
    69
  BOOST_STATIC_CONSTANT(bool, is_data_member = true);
williamr@2
    70
  BOOST_STATIC_CONSTANT(bool, is_function_member = false);
williamr@2
    71
};
williamr@2
    72
williamr@2
    73
// -- nonconst member functions --
williamr@2
    74
template<class T, class U>
williamr@2
    75
struct member_pointer<T (U::*)()> {
williamr@2
    76
  typedef T type;
williamr@2
    77
  typedef U class_type;
williamr@2
    78
  typedef U qualified_class_type;
williamr@2
    79
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
    80
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
    81
};
williamr@2
    82
template<class T, class U, class A1>
williamr@2
    83
struct member_pointer<T (U::*)(A1)> {
williamr@2
    84
  typedef T type;
williamr@2
    85
  typedef U class_type;
williamr@2
    86
  typedef U qualified_class_type;
williamr@2
    87
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
    88
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
    89
};
williamr@2
    90
template<class T, class U, class A1, class A2>
williamr@2
    91
struct member_pointer<T (U::*)(A1, A2)> {
williamr@2
    92
  typedef T type;
williamr@2
    93
  typedef U class_type;
williamr@2
    94
  typedef U qualified_class_type;
williamr@2
    95
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
    96
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
    97
};
williamr@2
    98
template<class T, class U, class A1, class A2, class A3>
williamr@2
    99
struct member_pointer<T (U::*)(A1, A2, A3)> {
williamr@2
   100
  typedef T type;
williamr@2
   101
  typedef U class_type;
williamr@2
   102
  typedef U qualified_class_type;
williamr@2
   103
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   104
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   105
};
williamr@2
   106
template<class T, class U, class A1, class A2, class A3, class A4>
williamr@2
   107
struct member_pointer<T (U::*)(A1, A2, A3, A4)> {
williamr@2
   108
  typedef T type;
williamr@2
   109
  typedef U class_type;
williamr@2
   110
  typedef U qualified_class_type;
williamr@2
   111
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   112
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   113
};
williamr@2
   114
template<class T, class U, class A1, class A2, class A3, class A4, class A5>
williamr@2
   115
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5)> {
williamr@2
   116
  typedef T type;
williamr@2
   117
  typedef U class_type;
williamr@2
   118
  typedef U qualified_class_type;
williamr@2
   119
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   120
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   121
};
williamr@2
   122
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   123
         class A6>
williamr@2
   124
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6)> {
williamr@2
   125
  typedef T type;
williamr@2
   126
  typedef U class_type;
williamr@2
   127
  typedef U qualified_class_type;
williamr@2
   128
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   129
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   130
};
williamr@2
   131
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   132
         class A6, class A7>
williamr@2
   133
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7)> {
williamr@2
   134
  typedef T type;
williamr@2
   135
  typedef U class_type;
williamr@2
   136
  typedef U qualified_class_type;
williamr@2
   137
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   138
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   139
};
williamr@2
   140
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   141
         class A6, class A7, class A8>
williamr@2
   142
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8)> {
williamr@2
   143
  typedef T type;
williamr@2
   144
  typedef U class_type;
williamr@2
   145
  typedef U qualified_class_type;
williamr@2
   146
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   147
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   148
};
williamr@2
   149
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   150
         class A6, class A7, class A8, class A9>
williamr@2
   151
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
williamr@2
   152
  typedef T type;
williamr@2
   153
  typedef U class_type;
williamr@2
   154
  typedef U qualified_class_type;
williamr@2
   155
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   156
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   157
};
williamr@2
   158
// -- const member functions --
williamr@2
   159
template<class T, class U>
williamr@2
   160
struct member_pointer<T (U::*)() const> {
williamr@2
   161
  typedef T type;
williamr@2
   162
  typedef U class_type;
williamr@2
   163
  typedef const U qualified_class_type;
williamr@2
   164
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   165
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   166
};
williamr@2
   167
template<class T, class U, class A1>
williamr@2
   168
struct member_pointer<T (U::*)(A1) const> {
williamr@2
   169
  typedef T type;
williamr@2
   170
  typedef U class_type;
williamr@2
   171
  typedef const U qualified_class_type;
williamr@2
   172
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   173
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   174
};
williamr@2
   175
template<class T, class U, class A1, class A2>
williamr@2
   176
struct member_pointer<T (U::*)(A1, A2) const> {
williamr@2
   177
  typedef T type;
williamr@2
   178
  typedef U class_type;
williamr@2
   179
  typedef const U qualified_class_type;
williamr@2
   180
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   181
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   182
};
williamr@2
   183
template<class T, class U, class A1, class A2, class A3>
williamr@2
   184
struct member_pointer<T (U::*)(A1, A2, A3) const> {
williamr@2
   185
  typedef T type;
williamr@2
   186
  typedef U class_type;
williamr@2
   187
  typedef const U qualified_class_type;
williamr@2
   188
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   189
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   190
};
williamr@2
   191
template<class T, class U, class A1, class A2, class A3, class A4>
williamr@2
   192
struct member_pointer<T (U::*)(A1, A2, A3, A4) const> {
williamr@2
   193
  typedef T type;
williamr@2
   194
  typedef U class_type;
williamr@2
   195
  typedef const U qualified_class_type;
williamr@2
   196
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   197
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   198
};
williamr@2
   199
template<class T, class U, class A1, class A2, class A3, class A4, class A5>
williamr@2
   200
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5) const> {
williamr@2
   201
  typedef T type;
williamr@2
   202
  typedef U class_type;
williamr@2
   203
  typedef const U qualified_class_type;
williamr@2
   204
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   205
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   206
};
williamr@2
   207
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   208
         class A6>
williamr@2
   209
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6) const> {
williamr@2
   210
  typedef T type;
williamr@2
   211
  typedef U class_type;
williamr@2
   212
  typedef const U qualified_class_type;
williamr@2
   213
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   214
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   215
};
williamr@2
   216
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   217
         class A6, class A7>
williamr@2
   218
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7) const> {
williamr@2
   219
  typedef T type;
williamr@2
   220
  typedef U class_type;
williamr@2
   221
  typedef const U qualified_class_type;
williamr@2
   222
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   223
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   224
};
williamr@2
   225
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   226
         class A6, class A7, class A8>
williamr@2
   227
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8) const> {
williamr@2
   228
  typedef T type;
williamr@2
   229
  typedef U class_type;
williamr@2
   230
  typedef const U qualified_class_type;
williamr@2
   231
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   232
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   233
};
williamr@2
   234
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   235
         class A6, class A7, class A8, class A9>
williamr@2
   236
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const> {
williamr@2
   237
  typedef T type;
williamr@2
   238
  typedef U class_type;
williamr@2
   239
  typedef const U qualified_class_type;
williamr@2
   240
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   241
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   242
};
williamr@2
   243
  // -- volatile --
williamr@2
   244
template<class T, class U>
williamr@2
   245
struct member_pointer<T (U::*)() volatile> {
williamr@2
   246
  typedef T type;
williamr@2
   247
  typedef U class_type;
williamr@2
   248
  typedef volatile U qualified_class_type;
williamr@2
   249
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   250
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   251
};
williamr@2
   252
template<class T, class U, class A1>
williamr@2
   253
struct member_pointer<T (U::*)(A1) volatile> {
williamr@2
   254
  typedef T type;
williamr@2
   255
  typedef U class_type;
williamr@2
   256
  typedef volatile U qualified_class_type;
williamr@2
   257
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   258
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   259
};
williamr@2
   260
template<class T, class U, class A1, class A2>
williamr@2
   261
struct member_pointer<T (U::*)(A1, A2) volatile> {
williamr@2
   262
  typedef T type;
williamr@2
   263
  typedef U class_type;
williamr@2
   264
  typedef volatile U qualified_class_type;
williamr@2
   265
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   266
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   267
};
williamr@2
   268
template<class T, class U, class A1, class A2, class A3>
williamr@2
   269
struct member_pointer<T (U::*)(A1, A2, A3) volatile> {
williamr@2
   270
  typedef T type;
williamr@2
   271
  typedef U class_type;
williamr@2
   272
  typedef volatile U qualified_class_type;
williamr@2
   273
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   274
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   275
};
williamr@2
   276
template<class T, class U, class A1, class A2, class A3, class A4>
williamr@2
   277
struct member_pointer<T (U::*)(A1, A2, A3, A4) volatile> {
williamr@2
   278
  typedef T type;
williamr@2
   279
  typedef U class_type;
williamr@2
   280
  typedef volatile U qualified_class_type;
williamr@2
   281
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   282
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   283
};
williamr@2
   284
template<class T, class U, class A1, class A2, class A3, class A4, class A5>
williamr@2
   285
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5) volatile> {
williamr@2
   286
  typedef T type;
williamr@2
   287
  typedef U class_type;
williamr@2
   288
  typedef volatile U qualified_class_type;
williamr@2
   289
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   290
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   291
};
williamr@2
   292
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   293
         class A6>
williamr@2
   294
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6) volatile> {
williamr@2
   295
  typedef T type;
williamr@2
   296
  typedef U class_type;
williamr@2
   297
  typedef volatile U qualified_class_type;
williamr@2
   298
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   299
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   300
};
williamr@2
   301
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   302
         class A6, class A7>
williamr@2
   303
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7) volatile> {
williamr@2
   304
  typedef T type;
williamr@2
   305
  typedef U class_type;
williamr@2
   306
  typedef volatile U qualified_class_type;
williamr@2
   307
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   308
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   309
};
williamr@2
   310
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   311
         class A6, class A7, class A8>
williamr@2
   312
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8) volatile> {
williamr@2
   313
  typedef T type;
williamr@2
   314
  typedef U class_type;
williamr@2
   315
  typedef volatile U qualified_class_type;
williamr@2
   316
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   317
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   318
};
williamr@2
   319
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   320
         class A6, class A7, class A8, class A9>
williamr@2
   321
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9) volatile> {
williamr@2
   322
  typedef T type;
williamr@2
   323
  typedef U class_type;
williamr@2
   324
  typedef volatile U qualified_class_type;
williamr@2
   325
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   326
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   327
};
williamr@2
   328
  // -- const volatile
williamr@2
   329
template<class T, class U>
williamr@2
   330
struct member_pointer<T (U::*)() const volatile> {
williamr@2
   331
  typedef T type;
williamr@2
   332
  typedef U class_type;
williamr@2
   333
  typedef const volatile U qualified_class_type;
williamr@2
   334
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   335
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   336
};
williamr@2
   337
template<class T, class U, class A1>
williamr@2
   338
struct member_pointer<T (U::*)(A1) const volatile> {
williamr@2
   339
  typedef T type;
williamr@2
   340
  typedef U class_type;
williamr@2
   341
  typedef const volatile U qualified_class_type;
williamr@2
   342
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   343
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   344
};
williamr@2
   345
template<class T, class U, class A1, class A2>
williamr@2
   346
struct member_pointer<T (U::*)(A1, A2) const volatile> {
williamr@2
   347
  typedef T type;
williamr@2
   348
  typedef U class_type;
williamr@2
   349
  typedef const volatile U qualified_class_type;
williamr@2
   350
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   351
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   352
};
williamr@2
   353
template<class T, class U, class A1, class A2, class A3>
williamr@2
   354
struct member_pointer<T (U::*)(A1, A2, A3) const volatile> {
williamr@2
   355
  typedef T type;
williamr@2
   356
  typedef U class_type;
williamr@2
   357
  typedef const volatile U qualified_class_type;
williamr@2
   358
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   359
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   360
};
williamr@2
   361
template<class T, class U, class A1, class A2, class A3, class A4>
williamr@2
   362
struct member_pointer<T (U::*)(A1, A2, A3, A4) const volatile> {
williamr@2
   363
  typedef T type;
williamr@2
   364
  typedef U class_type;
williamr@2
   365
  typedef const volatile U qualified_class_type;
williamr@2
   366
};
williamr@2
   367
template<class T, class U, class A1, class A2, class A3, class A4, class A5>
williamr@2
   368
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5) const volatile> {
williamr@2
   369
  typedef T type;
williamr@2
   370
  typedef U class_type;
williamr@2
   371
  typedef const volatile U qualified_class_type;
williamr@2
   372
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   373
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   374
};
williamr@2
   375
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   376
         class A6>
williamr@2
   377
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6) const volatile> {
williamr@2
   378
  typedef T type;
williamr@2
   379
  typedef U class_type;
williamr@2
   380
  typedef const volatile U qualified_class_type;
williamr@2
   381
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   382
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   383
};
williamr@2
   384
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   385
         class A6, class A7>
williamr@2
   386
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7) const volatile> {
williamr@2
   387
  typedef T type;
williamr@2
   388
  typedef U class_type;
williamr@2
   389
  typedef const volatile U qualified_class_type;
williamr@2
   390
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   391
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   392
};
williamr@2
   393
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   394
         class A6, class A7, class A8>
williamr@2
   395
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8) const volatile> {
williamr@2
   396
  typedef T type;
williamr@2
   397
  typedef U class_type;
williamr@2
   398
  typedef const volatile U qualified_class_type;
williamr@2
   399
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   400
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   401
};
williamr@2
   402
template<class T, class U, class A1, class A2, class A3, class A4, class A5,
williamr@2
   403
         class A6, class A7, class A8, class A9>
williamr@2
   404
struct member_pointer<T (U::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const volatile> {
williamr@2
   405
  typedef T type;
williamr@2
   406
  typedef U class_type;
williamr@2
   407
  typedef const volatile U qualified_class_type;
williamr@2
   408
  BOOST_STATIC_CONSTANT(bool, is_data_member = false);
williamr@2
   409
  BOOST_STATIC_CONSTANT(bool, is_function_member = true);
williamr@2
   410
};
williamr@2
   411
williamr@2
   412
} // detail
williamr@2
   413
williamr@2
   414
namespace detail {
williamr@2
   415
williamr@2
   416
  // this class holds a pointer to a member function and the object.
williamr@2
   417
  // when called, it just calls the member function with the parameters 
williamr@2
   418
  // provided
williamr@2
   419
williamr@2
   420
  // It would have been possible to use existing lambda_functors to represent
williamr@2
   421
  // a bound member function like this, but to have a separate template is 
williamr@2
   422
  // safer, since now this functor doesn't mix and match with lambda_functors
williamr@2
   423
  // only thing you can do with this is to call it
williamr@2
   424
williamr@2
   425
  // note that previously instantiated classes 
williamr@2
   426
  // (other_action<member_pointer_action> and member_pointer_action_helper
williamr@2
   427
  // guarantee, that A and B are 
williamr@2
   428
  // such types, that for objects a and b of corresponding types, a->*b leads 
williamr@2
   429
  // to the builtin ->* to be called. So types that would end in a  call to 
williamr@2
   430
  // a user defined ->* do not create a member_pointer_caller object.
williamr@2
   431
williamr@2
   432
template<class RET, class A, class B>
williamr@2
   433
class member_pointer_caller {
williamr@2
   434
  A a; B b;
williamr@2
   435
williamr@2
   436
public:
williamr@2
   437
  member_pointer_caller(const A& aa, const B& bb) : a(aa), b(bb) {}
williamr@2
   438
williamr@2
   439
  RET operator()() const { return (a->*b)(); } 
williamr@2
   440
williamr@2
   441
  template<class A1>
williamr@2
   442
  RET operator()(const A1& a1) const { return (a->*b)(a1); } 
williamr@2
   443
williamr@2
   444
  template<class A1, class A2>
williamr@2
   445
  RET operator()(const A1& a1, const A2& a2) const { return (a->*b)(a1, a2); } 
williamr@2
   446
williamr@2
   447
  template<class A1, class A2, class A3>
williamr@2
   448
  RET operator()(const A1& a1, const A2& a2, const A3& a3) const { 
williamr@2
   449
    return (a->*b)(a1, a2, a3); 
williamr@2
   450
  } 
williamr@2
   451
williamr@2
   452
  template<class A1, class A2, class A3, class A4>
williamr@2
   453
  RET operator()(const A1& a1, const A2& a2, const A3& a3, 
williamr@2
   454
                 const A4& a4) const { 
williamr@2
   455
    return (a->*b)(a1, a2, a3, a4); 
williamr@2
   456
  } 
williamr@2
   457
williamr@2
   458
  template<class A1, class A2, class A3, class A4, class A5>
williamr@2
   459
  RET operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, 
williamr@2
   460
                 const A5& a5) const { 
williamr@2
   461
    return (a->*b)(a1, a2, a3, a4, a5); 
williamr@2
   462
  } 
williamr@2
   463
williamr@2
   464
  template<class A1, class A2, class A3, class A4, class A5, class A6>
williamr@2
   465
  RET operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, 
williamr@2
   466
                 const A5& a5, const A6& a6) const { 
williamr@2
   467
    return (a->*b)(a1, a2, a3, a4, a5, a6); 
williamr@2
   468
  } 
williamr@2
   469
williamr@2
   470
  template<class A1, class A2, class A3, class A4, class A5, class A6, 
williamr@2
   471
           class A7>
williamr@2
   472
  RET operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, 
williamr@2
   473
                 const A5& a5, const A6& a6, const A7& a7) const { 
williamr@2
   474
    return (a->*b)(a1, a2, a3, a4, a5, a6, a7); 
williamr@2
   475
  } 
williamr@2
   476
williamr@2
   477
  template<class A1, class A2, class A3, class A4, class A5, class A6, 
williamr@2
   478
           class A7, class A8>
williamr@2
   479
  RET operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, 
williamr@2
   480
                 const A5& a5, const A6& a6, const A7& a7,
williamr@2
   481
                 const A8& a8) const { 
williamr@2
   482
    return (a->*b)(a1, a2, a3, a4, a5, a6, a7, a8); 
williamr@2
   483
  } 
williamr@2
   484
williamr@2
   485
  template<class A1, class A2, class A3, class A4, class A5, class A6, 
williamr@2
   486
           class A7, class A8, class A9>
williamr@2
   487
  RET operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4, 
williamr@2
   488
                 const A5& a5, const A6& a6, const A7& a7,
williamr@2
   489
                 const A8& a8, const A9& a9) const { 
williamr@2
   490
    return (a->*b)(a1, a2, a3, a4, a5, a6, a7, a8, a9); 
williamr@2
   491
  } 
williamr@2
   492
williamr@2
   493
};
williamr@2
   494
williamr@2
   495
// helper templates for return type deduction and action classes
williamr@2
   496
// different cases for data member, function member, neither
williamr@2
   497
williamr@2
   498
// true-true case
williamr@2
   499
template <bool Is_data_member, bool Is_function_member>
williamr@2
   500
struct member_pointer_action_helper;
williamr@2
   501
  // cannot be both, no body provided
williamr@2
   502
williamr@2
   503
  // data member case
williamr@2
   504
  // this means, that B is a data member and A is a pointer type,
williamr@2
   505
  // so either built-in ->* should be called, or there is an error
williamr@2
   506
template <>
williamr@2
   507
struct member_pointer_action_helper<true, false> {
williamr@2
   508
public:
williamr@2
   509
williamr@2
   510
  template<class RET, class A, class B>
williamr@2
   511
  static RET apply(A& a, B& b) { 
williamr@2
   512
    return a->*b; 
williamr@2
   513
  }
williamr@2
   514
williamr@2
   515
  template<class A, class B>
williamr@2
   516
  struct return_type {
williamr@2
   517
  private:
williamr@2
   518
    typedef typename detail::remove_reference_and_cv<B>::type plainB;
williamr@2
   519
williamr@2
   520
    typedef typename detail::member_pointer<plainB>::type type0;
williamr@2
   521
    // we remove the reference now, as we may have to add cv:s 
williamr@2
   522
    typedef typename boost::remove_reference<type0>::type type1;
williamr@2
   523
williamr@2
   524
    // A is a reference to pointer
williamr@2
   525
    // remove the top level cv qualifiers and reference
williamr@2
   526
    typedef typename 
williamr@2
   527
      detail::remove_reference_and_cv<A>::type non_ref_A;
williamr@2
   528
williamr@2
   529
    // A is a pointer type, so take the type pointed to
williamr@2
   530
    typedef typename ::boost::remove_pointer<non_ref_A>::type non_pointer_A; 
williamr@2
   531
williamr@2
   532
  public:
williamr@2
   533
    // For non-reference types, we must add const and/or volatile if
williamr@2
   534
    // the pointer type has these qualifiers
williamr@2
   535
    // If the member is a reference, these do not have any effect
williamr@2
   536
    //   (cv T == T if T is a reference type)
williamr@2
   537
    typedef typename detail::IF<
williamr@2
   538
      ::boost::is_const<non_pointer_A>::value, 
williamr@2
   539
      typename ::boost::add_const<type1>::type,
williamr@2
   540
      type1
williamr@2
   541
    >::RET type2;
williamr@2
   542
    typedef typename detail::IF<
williamr@2
   543
      ::boost::is_volatile<non_pointer_A>::value, 
williamr@2
   544
      typename ::boost::add_volatile<type2>::type,
williamr@2
   545
      type2
williamr@2
   546
    >::RET type3;
williamr@2
   547
    // add reference back
williamr@2
   548
    typedef typename ::boost::add_reference<type3>::type type;
williamr@2
   549
  };
williamr@2
   550
};
williamr@2
   551
williamr@2
   552
  // neither case
williamr@2
   553
template <>
williamr@2
   554
struct member_pointer_action_helper<false, false> {
williamr@2
   555
public:
williamr@2
   556
  template<class RET, class A, class B>
williamr@2
   557
  static RET apply(A& a, B& b) { 
williamr@2
   558
// not a built in member pointer operator, just call ->*
williamr@2
   559
    return a->*b; 
williamr@2
   560
  }
williamr@2
   561
  // an overloaded member pointer operators, user should have specified
williamr@2
   562
  // the return type
williamr@2
   563
  // At this point we know that there is no matching specialization for
williamr@2
   564
  // return_type_2, so try return_type_2_plain
williamr@2
   565
  template<class A, class B>
williamr@2
   566
  struct return_type {
williamr@2
   567
williamr@2
   568
    typedef typename plain_return_type_2<
williamr@2
   569
      other_action<member_pointer_action>, A, B
williamr@2
   570
    >::type type;
williamr@2
   571
  };
williamr@2
   572
  
williamr@2
   573
};
williamr@2
   574
williamr@2
   575
williamr@2
   576
// member pointer function case
williamr@2
   577
// This is a built in ->* call for a member function, 
williamr@2
   578
// the only thing that you can do with that, is to give it some arguments
williamr@2
   579
// note, it is guaranteed that A is a pointer type, and thus it cannot
williamr@2
   580
// be a call to overloaded ->*
williamr@2
   581
template <>
williamr@2
   582
struct member_pointer_action_helper<false, true> {
williamr@2
   583
  public:
williamr@2
   584
williamr@2
   585
  template<class RET, class A, class B>
williamr@2
   586
  static RET apply(A& a, B& b) { 
williamr@2
   587
    typedef typename ::boost::remove_cv<B>::type plainB;
williamr@2
   588
    typedef typename detail::member_pointer<plainB>::type ret_t; 
williamr@2
   589
    typedef typename ::boost::remove_cv<A>::type plainA;
williamr@2
   590
williamr@2
   591
    // we always strip cv:s to 
williamr@2
   592
    // make the two routes (calling and type deduction)
williamr@2
   593
    // to give the same results (and the const does not make any functional
williamr@2
   594
    // difference)
williamr@2
   595
    return detail::member_pointer_caller<ret_t, plainA, plainB>(a, b); 
williamr@2
   596
  }
williamr@2
   597
williamr@2
   598
  template<class A, class B>
williamr@2
   599
  struct return_type {
williamr@2
   600
    typedef typename detail::remove_reference_and_cv<B>::type plainB;
williamr@2
   601
    typedef typename detail::member_pointer<plainB>::type ret_t; 
williamr@2
   602
    typedef typename detail::remove_reference_and_cv<A>::type plainA; 
williamr@2
   603
williamr@2
   604
    typedef detail::member_pointer_caller<ret_t, plainA, plainB> type; 
williamr@2
   605
  };
williamr@2
   606
};
williamr@2
   607
williamr@2
   608
} // detail
williamr@2
   609
williamr@2
   610
template<> class other_action<member_pointer_action>  {
williamr@2
   611
public:
williamr@2
   612
  template<class RET, class A, class B>
williamr@2
   613
  static RET apply(A& a, B& b) {
williamr@2
   614
    typedef typename 
williamr@2
   615
      ::boost::remove_cv<B>::type plainB;
williamr@2
   616
williamr@2
   617
    return detail::member_pointer_action_helper<
williamr@2
   618
        boost::is_pointer<A>::value && 
williamr@2
   619
          detail::member_pointer<plainB>::is_data_member,
williamr@2
   620
        boost::is_pointer<A>::value && 
williamr@2
   621
          detail::member_pointer<plainB>::is_function_member
williamr@2
   622
      >::template apply<RET>(a, b); 
williamr@2
   623
    }
williamr@2
   624
};
williamr@2
   625
williamr@2
   626
  // return type deduction --
williamr@2
   627
williamr@2
   628
  // If the right argument is a pointer to data member, 
williamr@2
   629
  // and the left argument is of compatible pointer to class type
williamr@2
   630
  // return type is a reference to the data member type
williamr@2
   631
williamr@2
   632
  // if right argument is a pointer to a member function, and the left 
williamr@2
   633
  // argument is of a compatible type, the return type is a 
williamr@2
   634
  // member_pointer_caller (see above)
williamr@2
   635
williamr@2
   636
  // Otherwise, return type deduction fails. There is either an error, 
williamr@2
   637
  // or the user is trying to call an overloaded ->*
williamr@2
   638
  // In such a case either ret<> must be used, or a return_type_2 user 
williamr@2
   639
  // defined specialization must be provided
williamr@2
   640
williamr@2
   641
williamr@2
   642
template<class A, class B>
williamr@2
   643
struct return_type_2<other_action<member_pointer_action>, A, B> {
williamr@2
   644
private:
williamr@2
   645
  typedef typename 
williamr@2
   646
    detail::remove_reference_and_cv<B>::type plainB;
williamr@2
   647
public:
williamr@2
   648
  typedef typename 
williamr@2
   649
    detail::member_pointer_action_helper<
williamr@2
   650
      detail::member_pointer<plainB>::is_data_member,
williamr@2
   651
      detail::member_pointer<plainB>::is_function_member
williamr@2
   652
    >::template return_type<A, B>::type type; 
williamr@2
   653
};
williamr@2
   654
williamr@2
   655
  // this is the way the generic lambda_functor_base functions instantiate
williamr@2
   656
  // return type deduction. We turn it into return_type_2, so that the 
williamr@2
   657
  // user can provide specializations on that level.
williamr@2
   658
template<class Args>
williamr@2
   659
struct return_type_N<other_action<member_pointer_action>, Args> {
williamr@2
   660
  typedef typename boost::tuples::element<0, Args>::type A;
williamr@2
   661
  typedef typename boost::tuples::element<1, Args>::type B;
williamr@2
   662
  typedef typename 
williamr@2
   663
    return_type_2<other_action<member_pointer_action>, 
williamr@2
   664
                  typename boost::remove_reference<A>::type, 
williamr@2
   665
                  typename boost::remove_reference<B>::type
williamr@2
   666
                 >::type type;
williamr@2
   667
};
williamr@2
   668
williamr@2
   669
williamr@2
   670
template<class Arg1, class Arg2>
williamr@2
   671
inline const
williamr@2
   672
lambda_functor<
williamr@2
   673
  lambda_functor_base<
williamr@2
   674
    action<2, other_action<member_pointer_action> >,
williamr@2
   675
    tuple<lambda_functor<Arg1>, typename const_copy_argument<Arg2>::type>
williamr@2
   676
  >
williamr@2
   677
>
williamr@2
   678
operator->*(const lambda_functor<Arg1>& a1, const Arg2& a2)
williamr@2
   679
{
williamr@2
   680
  return 
williamr@2
   681
      lambda_functor_base<
williamr@2
   682
        action<2, other_action<member_pointer_action> >,
williamr@2
   683
        tuple<lambda_functor<Arg1>, typename const_copy_argument<Arg2>::type>
williamr@2
   684
      >
williamr@2
   685
      (tuple<lambda_functor<Arg1>, 
williamr@2
   686
             typename const_copy_argument<Arg2>::type>(a1, a2));
williamr@2
   687
}
williamr@2
   688
williamr@2
   689
template<class Arg1, class Arg2>
williamr@2
   690
inline const
williamr@2
   691
lambda_functor<
williamr@2
   692
  lambda_functor_base<
williamr@2
   693
    action<2, other_action<member_pointer_action> >,
williamr@2
   694
    tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
williamr@2
   695
  >
williamr@2
   696
>
williamr@2
   697
operator->*(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2)
williamr@2
   698
{
williamr@2
   699
  return 
williamr@2
   700
      lambda_functor_base<
williamr@2
   701
        action<2, other_action<member_pointer_action> >,
williamr@2
   702
        tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
williamr@2
   703
      >
williamr@2
   704
    (tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2));
williamr@2
   705
}
williamr@2
   706
williamr@2
   707
template<class Arg1, class Arg2>
williamr@2
   708
inline const
williamr@2
   709
lambda_functor<
williamr@2
   710
  lambda_functor_base<
williamr@2
   711
    action<2, other_action<member_pointer_action> >,
williamr@2
   712
    tuple<typename const_copy_argument<Arg1>::type, lambda_functor<Arg2> >
williamr@2
   713
  >
williamr@2
   714
>
williamr@2
   715
operator->*(const Arg1& a1, const lambda_functor<Arg2>& a2)
williamr@2
   716
{
williamr@2
   717
  return 
williamr@2
   718
      lambda_functor_base<
williamr@2
   719
        action<2, other_action<member_pointer_action> >,
williamr@2
   720
        tuple<typename const_copy_argument<Arg1>::type, lambda_functor<Arg2> >
williamr@2
   721
      >
williamr@2
   722
      (tuple<typename const_copy_argument<Arg1>::type, 
williamr@2
   723
             lambda_functor<Arg2> >(a1, a2));
williamr@2
   724
}
williamr@2
   725
williamr@2
   726
williamr@2
   727
} // namespace lambda 
williamr@2
   728
} // namespace boost
williamr@2
   729
williamr@2
   730
williamr@2
   731
#endif
williamr@2
   732
williamr@2
   733
williamr@2
   734
williamr@2
   735
williamr@2
   736
williamr@2
   737