annotate DEPENDENCIES/generic/include/boost/lambda/detail/arity_code.hpp @ 133:4acb5d8d80b6 tip

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