1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/lambda/detail/arity_code.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,110 @@
1.4 +// -- Boost Lambda Library -------------------------------------------------
1.5 +
1.6 +// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
1.7 +//
1.8 +// Distributed under the Boost Software License, Version 1.0. (See
1.9 +// accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//
1.12 +// For more information, see www.boost.org
1.13 +
1.14 +// --------------------------------------------------
1.15 +
1.16 +#ifndef BOOST_LAMBDA_ARITY_CODE_HPP
1.17 +#define BOOST_LAMBDA_ARITY_CODE_HPP
1.18 +
1.19 +#include "boost/type_traits/cv_traits.hpp"
1.20 +#include "boost/type_traits/transform_traits.hpp"
1.21 +
1.22 +namespace boost {
1.23 +namespace lambda {
1.24 +
1.25 +// These constants state, whether a lambda_functor instantiation results from
1.26 +// an expression which contains no placeholders (NONE),
1.27 +// only free1 placeholders (FIRST),
1.28 +// free2 placeholders and maybe free1 placeholders (SECOND),
1.29 +// free3 and maybe free1 and free2 placeholders (THIRD),
1.30 +// freeE placeholders and maybe free1 and free2 (EXCEPTION).
1.31 +// RETHROW means, that a rethrow expression is used somewhere in the lambda_functor.
1.32 +
1.33 +enum { NONE = 0x00, // Notice we are using bits as flags here.
1.34 + FIRST = 0x01,
1.35 + SECOND = 0x02,
1.36 + THIRD = 0x04,
1.37 + EXCEPTION = 0x08,
1.38 + RETHROW = 0x10};
1.39 +
1.40 +
1.41 +template<class T>
1.42 +struct get_tuple_arity;
1.43 +
1.44 +namespace detail {
1.45 +
1.46 +template <class T> struct get_arity_;
1.47 +
1.48 +} // end detail;
1.49 +
1.50 +template <class T> struct get_arity {
1.51 +
1.52 + BOOST_STATIC_CONSTANT(int, value = detail::get_arity_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type>::value);
1.53 +
1.54 +};
1.55 +
1.56 +namespace detail {
1.57 +
1.58 +template<class T>
1.59 +struct get_arity_ {
1.60 + BOOST_STATIC_CONSTANT(int, value = 0);
1.61 +};
1.62 +
1.63 +template<class T>
1.64 +struct get_arity_<lambda_functor<T> > {
1.65 + BOOST_STATIC_CONSTANT(int, value = get_arity<T>::value);
1.66 +};
1.67 +
1.68 +template<class Action, class Args>
1.69 +struct get_arity_<lambda_functor_base<Action, Args> > {
1.70 + BOOST_STATIC_CONSTANT(int, value = get_tuple_arity<Args>::value);
1.71 +};
1.72 +
1.73 +template<int I>
1.74 +struct get_arity_<placeholder<I> > {
1.75 + BOOST_STATIC_CONSTANT(int, value = I);
1.76 +};
1.77 +
1.78 +} // detail
1.79 +
1.80 +template<class T>
1.81 +struct get_tuple_arity {
1.82 + BOOST_STATIC_CONSTANT(int, value = get_arity<typename T::head_type>::value | get_tuple_arity<typename T::tail_type>::value);
1.83 +};
1.84 +
1.85 +
1.86 +template<>
1.87 +struct get_tuple_arity<null_type> {
1.88 + BOOST_STATIC_CONSTANT(int, value = 0);
1.89 +};
1.90 +
1.91 +
1.92 + // Does T have placeholder<I> as it's subexpression?
1.93 +
1.94 +template<class T, int I>
1.95 +struct has_placeholder {
1.96 + BOOST_STATIC_CONSTANT(bool, value = (get_arity<T>::value & I) != 0);
1.97 +};
1.98 +
1.99 +template<int I, int J>
1.100 +struct includes_placeholder {
1.101 + BOOST_STATIC_CONSTANT(bool, value = (J & I) != 0);
1.102 +};
1.103 +
1.104 +template<int I, int J>
1.105 +struct lacks_placeholder {
1.106 + BOOST_STATIC_CONSTANT(bool, value = ((J & I) == 0));
1.107 +};
1.108 +
1.109 +
1.110 +} // namespace lambda
1.111 +} // namespace boost
1.112 +
1.113 +#endif