Chris@16: // -- Boost Lambda Library ------------------------------------------------- Chris@16: Chris@16: // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see www.boost.org Chris@16: Chris@16: // -------------------------------------------------- Chris@16: Chris@16: #ifndef BOOST_LAMBDA_ARITY_CODE_HPP Chris@16: #define BOOST_LAMBDA_ARITY_CODE_HPP Chris@16: Chris@16: #include "boost/type_traits/cv_traits.hpp" Chris@16: #include "boost/type_traits/transform_traits.hpp" Chris@16: Chris@16: namespace boost { Chris@16: namespace lambda { Chris@16: Chris@16: // These constants state, whether a lambda_functor instantiation results from Chris@16: // an expression which contains no placeholders (NONE), Chris@16: // only free1 placeholders (FIRST), Chris@16: // free2 placeholders and maybe free1 placeholders (SECOND), Chris@16: // free3 and maybe free1 and free2 placeholders (THIRD), Chris@16: // freeE placeholders and maybe free1 and free2 (EXCEPTION). Chris@16: // RETHROW means, that a rethrow expression is used somewhere in the lambda_functor. Chris@16: Chris@16: enum { NONE = 0x00, // Notice we are using bits as flags here. Chris@16: FIRST = 0x01, Chris@16: SECOND = 0x02, Chris@16: THIRD = 0x04, Chris@16: EXCEPTION = 0x08, Chris@16: RETHROW = 0x10}; Chris@16: Chris@16: Chris@16: template Chris@16: struct get_tuple_arity; Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: template struct get_arity_; Chris@16: Chris@16: } // end detail; Chris@16: Chris@16: template struct get_arity { Chris@16: Chris@16: BOOST_STATIC_CONSTANT(int, value = detail::get_arity_::type>::type>::value); Chris@16: Chris@16: }; Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: template Chris@16: struct get_arity_ { Chris@16: BOOST_STATIC_CONSTANT(int, value = 0); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct get_arity_ > { Chris@16: BOOST_STATIC_CONSTANT(int, value = get_arity::value); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct get_arity_ > { Chris@16: BOOST_STATIC_CONSTANT(int, value = get_tuple_arity::value); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct get_arity_ > { Chris@16: BOOST_STATIC_CONSTANT(int, value = I); Chris@16: }; Chris@16: Chris@16: } // detail Chris@16: Chris@16: template Chris@16: struct get_tuple_arity { Chris@16: BOOST_STATIC_CONSTANT(int, value = get_arity::value | get_tuple_arity::value); Chris@16: }; Chris@16: Chris@16: Chris@16: template<> Chris@16: struct get_tuple_arity { Chris@16: BOOST_STATIC_CONSTANT(int, value = 0); Chris@16: }; Chris@16: Chris@16: Chris@16: // Does T have placeholder as it's subexpression? Chris@16: Chris@16: template Chris@16: struct has_placeholder { Chris@16: BOOST_STATIC_CONSTANT(bool, value = (get_arity::value & I) != 0); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct includes_placeholder { Chris@16: BOOST_STATIC_CONSTANT(bool, value = (J & I) != 0); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct lacks_placeholder { Chris@16: BOOST_STATIC_CONSTANT(bool, value = ((J & I) == 0)); Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace lambda Chris@16: } // namespace boost Chris@16: Chris@16: #endif