epoc32/include/stdapis/boost/lambda/detail/arity_code.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 -------------------------------------------------
williamr@2
     2
williamr@2
     3
// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
williamr@2
     4
//
williamr@2
     5
// Distributed under the Boost Software License, Version 1.0. (See
williamr@2
     6
// accompanying file LICENSE_1_0.txt or copy at
williamr@2
     7
// http://www.boost.org/LICENSE_1_0.txt)
williamr@2
     8
//
williamr@2
     9
// For more information, see www.boost.org
williamr@2
    10
williamr@2
    11
// --------------------------------------------------
williamr@2
    12
williamr@2
    13
#ifndef BOOST_LAMBDA_ARITY_CODE_HPP
williamr@2
    14
#define BOOST_LAMBDA_ARITY_CODE_HPP
williamr@2
    15
williamr@2
    16
#include "boost/type_traits/cv_traits.hpp"
williamr@2
    17
#include "boost/type_traits/transform_traits.hpp"
williamr@2
    18
williamr@2
    19
namespace boost { 
williamr@2
    20
namespace lambda {
williamr@2
    21
williamr@2
    22
// These constants state, whether a lambda_functor instantiation results from 
williamr@2
    23
// an expression which contains no placeholders (NONE), 
williamr@2
    24
// only free1 placeholders (FIRST), 
williamr@2
    25
// free2 placeholders and maybe free1 placeholders (SECOND),
williamr@2
    26
// free3 and maybe free1 and free2 placeholders (THIRD),
williamr@2
    27
// freeE placeholders and maybe free1 and free2  (EXCEPTION).
williamr@2
    28
// RETHROW means, that a rethrow expression is used somewhere in the lambda_functor.
williamr@2
    29
williamr@2
    30
enum { NONE             = 0x00, // Notice we are using bits as flags here.
williamr@2
    31
       FIRST            = 0x01, 
williamr@2
    32
       SECOND           = 0x02, 
williamr@2
    33
       THIRD            = 0x04, 
williamr@2
    34
       EXCEPTION        = 0x08, 
williamr@2
    35
       RETHROW          = 0x10};
williamr@2
    36
williamr@2
    37
williamr@2
    38
template<class T>
williamr@2
    39
struct get_tuple_arity;
williamr@2
    40
williamr@2
    41
namespace detail {
williamr@2
    42
williamr@2
    43
template <class T> struct get_arity_;
williamr@2
    44
williamr@2
    45
} // end detail;
williamr@2
    46
williamr@2
    47
template <class T> struct get_arity {
williamr@2
    48
williamr@2
    49
  BOOST_STATIC_CONSTANT(int, value = detail::get_arity_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type>::value);
williamr@2
    50
williamr@2
    51
};
williamr@2
    52
williamr@2
    53
namespace detail {
williamr@2
    54
williamr@2
    55
template<class T>
williamr@2
    56
struct get_arity_ {
williamr@2
    57
  BOOST_STATIC_CONSTANT(int, value = 0);
williamr@2
    58
};
williamr@2
    59
williamr@2
    60
template<class T>
williamr@2
    61
struct get_arity_<lambda_functor<T> > {
williamr@2
    62
  BOOST_STATIC_CONSTANT(int, value = get_arity<T>::value);
williamr@2
    63
};
williamr@2
    64
williamr@2
    65
template<class Action, class Args>
williamr@2
    66
struct get_arity_<lambda_functor_base<Action, Args> > {
williamr@2
    67
  BOOST_STATIC_CONSTANT(int, value = get_tuple_arity<Args>::value);
williamr@2
    68
};
williamr@2
    69
williamr@2
    70
template<int I>
williamr@2
    71
struct get_arity_<placeholder<I> > {
williamr@2
    72
  BOOST_STATIC_CONSTANT(int, value = I);
williamr@2
    73
};
williamr@2
    74
williamr@2
    75
} // detail 
williamr@2
    76
williamr@2
    77
template<class T>
williamr@2
    78
struct get_tuple_arity {
williamr@2
    79
  BOOST_STATIC_CONSTANT(int, value = get_arity<typename T::head_type>::value | get_tuple_arity<typename T::tail_type>::value);
williamr@2
    80
};
williamr@2
    81
williamr@2
    82
williamr@2
    83
template<>
williamr@2
    84
struct get_tuple_arity<null_type> {
williamr@2
    85
  BOOST_STATIC_CONSTANT(int, value = 0);
williamr@2
    86
};
williamr@2
    87
williamr@2
    88
williamr@2
    89
  // Does T have placeholder<I> as it's subexpression?
williamr@2
    90
williamr@2
    91
template<class T, int I>
williamr@2
    92
struct has_placeholder {
williamr@2
    93
  BOOST_STATIC_CONSTANT(bool, value = (get_arity<T>::value & I) != 0);
williamr@2
    94
}; 
williamr@2
    95
williamr@2
    96
template<int I, int J>
williamr@2
    97
struct includes_placeholder {
williamr@2
    98
  BOOST_STATIC_CONSTANT(bool, value = (J & I) != 0);
williamr@2
    99
};
williamr@2
   100
williamr@2
   101
template<int I, int J>
williamr@2
   102
struct lacks_placeholder {
williamr@2
   103
  BOOST_STATIC_CONSTANT(bool, value = ((J & I) == 0));
williamr@2
   104
};
williamr@2
   105
williamr@2
   106
williamr@2
   107
} // namespace lambda
williamr@2
   108
} // namespace boost
williamr@2
   109
williamr@2
   110
#endif