Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:06

0001 // -- Boost Lambda Library -------------------------------------------------
0002 
0003 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // For more information, see www.boost.org
0010 
0011 // --------------------------------------------------
0012 
0013 #ifndef BOOST_LAMBDA_ARITY_CODE_HPP
0014 #define BOOST_LAMBDA_ARITY_CODE_HPP
0015 
0016 #include "boost/type_traits/cv_traits.hpp"
0017 #include "boost/type_traits/transform_traits.hpp"
0018 
0019 namespace boost { 
0020 namespace lambda {
0021 
0022 // These constants state, whether a lambda_functor instantiation results from 
0023 // an expression which contains no placeholders (NONE), 
0024 // only free1 placeholders (FIRST), 
0025 // free2 placeholders and maybe free1 placeholders (SECOND),
0026 // free3 and maybe free1 and free2 placeholders (THIRD),
0027 // freeE placeholders and maybe free1 and free2  (EXCEPTION).
0028 // RETHROW means, that a rethrow expression is used somewhere in the lambda_functor.
0029 
0030 enum { NONE             = 0x00, // Notice we are using bits as flags here.
0031        FIRST            = 0x01, 
0032        SECOND           = 0x02, 
0033        THIRD            = 0x04, 
0034        EXCEPTION        = 0x08, 
0035        RETHROW          = 0x10};
0036 
0037 
0038 template<class T>
0039 struct get_tuple_arity;
0040 
0041 namespace detail {
0042 
0043 template <class T> struct get_arity_;
0044 
0045 } // end detail;
0046 
0047 template <class T> struct get_arity {
0048 
0049   BOOST_STATIC_CONSTANT(int, value = detail::get_arity_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type>::value);
0050 
0051 };
0052 
0053 namespace detail {
0054 
0055 template<class T>
0056 struct get_arity_ {
0057   BOOST_STATIC_CONSTANT(int, value = 0);
0058 };
0059 
0060 template<class T>
0061 struct get_arity_<lambda_functor<T> > {
0062   BOOST_STATIC_CONSTANT(int, value = get_arity<T>::value);
0063 };
0064 
0065 template<class Action, class Args>
0066 struct get_arity_<lambda_functor_base<Action, Args> > {
0067   BOOST_STATIC_CONSTANT(int, value = get_tuple_arity<Args>::value);
0068 };
0069 
0070 template<int I>
0071 struct get_arity_<placeholder<I> > {
0072   BOOST_STATIC_CONSTANT(int, value = I);
0073 };
0074 
0075 } // detail 
0076 
0077 template<class T>
0078 struct get_tuple_arity {
0079   BOOST_STATIC_CONSTANT(int, value = get_arity<typename T::head_type>::value | get_tuple_arity<typename T::tail_type>::value);
0080 };
0081 
0082 
0083 template<>
0084 struct get_tuple_arity<null_type> {
0085   BOOST_STATIC_CONSTANT(int, value = 0);
0086 };
0087 
0088 
0089   // Does T have placeholder<I> as it's subexpression?
0090 
0091 template<class T, int I>
0092 struct has_placeholder {
0093   BOOST_STATIC_CONSTANT(bool, value = (get_arity<T>::value & I) != 0);
0094 }; 
0095 
0096 template<int I, int J>
0097 struct includes_placeholder {
0098   BOOST_STATIC_CONSTANT(bool, value = (J & I) != 0);
0099 };
0100 
0101 template<int I, int J>
0102 struct lacks_placeholder {
0103   BOOST_STATIC_CONSTANT(bool, value = ((J & I) == 0));
0104 };
0105 
0106 
0107 } // namespace lambda
0108 } // namespace boost
0109 
0110 #endif