Ticket #864: djw_lambda_result.patch
File djw_lambda_result.patch, 7.2 KB (added by , 13 years ago) |
---|
-
boost/lambda/detail/function_adaptors.hpp
RCS file: /cvsroot/boost/boost/boost/lambda/detail/function_adaptors.hpp,v retrieving revision 1.7 diff -d -u -r1.7 function_adaptors.hpp
12 12 #ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP 13 13 #define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP 14 14 15 #include "boost/mpl/has_template_xxx.hpp" 16 #include "boost/preprocessor/repetition/enum.hpp" 17 #include "boost/preprocessor/repetition/repeat.hpp" 18 #include "boost/tuple/tuple.hpp" 15 19 #include "boost/type_traits/same_traits.hpp" 20 #include "boost/utility/result_of.hpp" 16 21 17 22 namespace boost { 18 23 namespace lambda { 19 24 20 25 template <class Func> struct function_adaptor { 21 26 27 typedef typename detail::remove_reference_and_cv<Func>::type plainF; 28 29 #if !defined(BOOST_NO_RESULT_OF) 30 // Support functors that use the boost::result_of return type convention. 31 template<class Tuple, int Length, bool HasSig> 32 struct result_converter; 33 template<class Tuple, int Length> 34 struct result_converter<Tuple, Length, true> 35 : plainF::template sig<Tuple> 36 {}; 37 #define BOOST_LAMBDA_RESULT_CONVERTER_ARGS(z, n, _) \ 38 typename tuples::element<n, typename Tuple::tail_type>::type \ 39 /**/ 40 #define BOOST_LAMBDA_RESULT_CONVERTER(z, n, _) \ 41 template<class Tuple> \ 42 struct result_converter<Tuple, n, false> \ 43 : result_of< \ 44 plainF( \ 45 BOOST_PP_ENUM(n, BOOST_LAMBDA_RESULT_CONVERTER_ARGS, _) \ 46 ) \ 47 > \ 48 {}; \ 49 /**/ 50 BOOST_PP_REPEAT( 51 BOOST_RESULT_OF_NUM_ARGS 52 , BOOST_LAMBDA_RESULT_CONVERTER 53 , _ 54 ) 55 #undef BOOST_LAMBDA_RESULT_CONVERTER 56 #undef BOOST_LAMBDA_RESULT_CONVERTER_ARGS 57 58 BOOST_MPL_HAS_TEMPLATE_XXX_TRAIT_NAMED_DEF(has_template_sig, sig, 1, true) 59 22 60 // we do not know the return type off-hand, we must ask it from Func 61 // To sig we pass a cons list, where the head is the function object type 62 // itself (potentially cv-qualified) 63 // and the tail contains the types of the actual arguments to be passed 64 // to the function object. The arguments can be cv qualified 65 // as well. 66 template <class Args> 67 struct sig 68 : result_converter< 69 Args 70 , tuples::length<typename Args::tail_type>::value 71 , has_template_sig<plainF, Args>::value 72 > 73 {}; 74 #else // BOOST_NO_RESULT_OF 23 75 template <class Args> class sig { 24 76 typedef typename Args::head_type F; 25 typedef typename detail::remove_reference_and_cv<Func>::type plainF;26 77 public: 27 // To sig we pass a cons list, where the head is the function object type28 // itself (potentially cv-qualified)29 // and the tail contains the types of the actual arguments to be passed30 // to the function object. The arguments can be cv qualified31 // as well.32 78 typedef typename plainF::template sig<Args>::type type; 33 79 }; 80 #endif // BOOST_NO_RESULT_OF 34 81 35 82 template<class RET, class A1> 36 83 static RET apply(A1& a1) { -
boost/lambda/detail/lambda_functors.hpp
RCS file: /cvsroot/boost/boost/boost/lambda/detail/lambda_functors.hpp,v retrieving revision 1.8 diff -d -u -r1.8 lambda_functors.hpp
13 13 #ifndef BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP 14 14 #define BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP 15 15 16 #include <boost/preprocessor/control/if.hpp> 17 #include <boost/preprocessor/repetition/enum_params.hpp> 18 #include <boost/utility/result_of.hpp> 19 16 20 namespace boost { 17 21 namespace lambda { 18 22 … … 134 138 inherited::template sig<null_type>::type 135 139 nullary_return_type; 136 140 141 // Support for boost::result_of. 142 #define BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE(n) \ 143 typename F::nullary_return_type \ 144 /**/ 145 #define BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE(n) \ 146 typename sig<tuple<F, BOOST_PP_ENUM_PARAMS(n, A)> >::type \ 147 /**/ 148 #define BOOST_LAMBDA_FUNCTOR_RESULT_TYPE(n) \ 149 BOOST_PP_IF( \ 150 n \ 151 , BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE \ 152 , BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE \ 153 )(n) \ 154 /**/ 155 BOOST_VARIABLE_ARITY_FUNCTOR_RESULT( 156 0 157 , BOOST_RESULT_OF_NUM_ARGS 158 , BOOST_LAMBDA_FUNCTOR_RESULT_TYPE 159 ) 160 #undef BOOST_LAMBDA_FUNCTOR_RESULT_TYPE 161 #undef BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE 162 #undef BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE 163 137 164 nullary_return_type operator()() const { 138 165 return inherited::template 139 166 call<nullary_return_type> -
boost/utility/result_of.hpp
RCS file: /cvsroot/boost/boost/boost/utility/result_of.hpp,v retrieving revision 1.10 diff -d -u -r1.10 result_of.hpp
22 22 # define BOOST_RESULT_OF_NUM_ARGS 10 23 23 #endif 24 24 25 #define BOOST_RESULT_PARTIAL_SPECIALIZATION(z, n, macro) \ 26 template < \ 27 class F \ 28 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) \ 29 > \ 30 struct result<F(BOOST_PP_ENUM_PARAMS(n, A))> { \ 31 typedef macro(n) type; \ 32 }; \ 33 /**/ 34 #define BOOST_VARIABLE_ARITY_FUNCTOR_RESULT(first, last, macro) \ 35 template <class F> struct result; \ 36 BOOST_PP_REPEAT_FROM_TO( \ 37 first, last \ 38 , BOOST_RESULT_PARTIAL_SPECIALIZATION \ 39 , macro \ 40 ) \ 41 /**/ 42 #define BOOST_FIXED_ARITY_FUNCTOR_RESULT(n, data) \ 43 template <class F> struct result; \ 44 template < \ 45 class F \ 46 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) \ 47 > \ 48 struct result<F(BOOST_PP_ENUM_PARAMS(n, A))> { \ 49 typedef data type; \ 50 }; \ 51 /**/ 52 25 53 namespace boost { 26 54 27 55 template<typename F> struct result_of; -
new file libs/lambda/test/Jamfile.v2
RCS file: libs/lambda/test/Jamfile.v2 diff -N libs/lambda/test/Jamfile.v2
- + 1 # Lambda library 2 3 # Copyright (C) 2001-2007 Jaakko Järvi, Daniel Walker 4 5 # Use, modification and distribution is subject to the Boost Software License, 6 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 # http://www.boost.org/LICENSE_1_0.txt) 8 9 # For more information, see http://www.boost.org/ 10 11 # bring in rules for testing 12 import testing ; 13 14 test-suite lambda 15 : 16 [ run algorithm_test.cpp ] 17 18 [ run bind_tests_simple.cpp ] 19 20 [ run bind_tests_advanced.cpp ] 21 22 [ run bind_tests_simple_f_refs.cpp ] 23 24 [ run bll_and_function.cpp ] 25 26 [ run cast_test.cpp ] 27 28 [ run constructor_tests.cpp ] 29 30 [ run control_structures.cpp ] 31 32 [ run exception_test.cpp ] 33 34 [ run extending_rt_traits.cpp ] 35 36 [ run is_instance_of_test.cpp ] 37 38 [ run member_pointer_test.cpp ] 39 40 [ run operator_tests_simple.cpp ] 41 42 [ run phoenix_control_structures.cpp ] 43 44 [ run switch_construct.cpp ] 45 ;