Index: 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 --- boost/lambda/detail/function_adaptors.hpp 27 Jul 2004 03:43:27 -0000 1.7 +++ boost/lambda/detail/function_adaptors.hpp 21 Mar 2007 15:36:51 -0000 @@ -12,26 +12,65 @@ #ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP #define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP +#include "boost/mpl/has_template_xxx.hpp" +#include "boost/preprocessor/repetition/enum.hpp" +#include "boost/preprocessor/repetition/repeat.hpp" +#include "boost/tuple/tuple.hpp" #include "boost/type_traits/same_traits.hpp" +#include "boost/utility/result_of.hpp" namespace boost { namespace lambda { template struct function_adaptor { - // we do not know the return type off-hand, we must ask it from Func - template class sig { - typedef typename Args::head_type F; - typedef typename detail::remove_reference_and_cv::type plainF; - public: - // To sig we pass a cons list, where the head is the function object type - // itself (potentially cv-qualified) - // and the tail contains the types of the actual arguments to be passed - // to the function object. The arguments can be cv qualified - // as well. - typedef typename plainF::template sig::type type; - }; + typedef typename detail::remove_reference_and_cv::type plainF; + // Support functors that use the boost::result_of return type convention. + template + struct result_converter; + template + struct result_converter + : plainF::template sig + {}; +#define BOOST_LAMBDA_RESULT_CONVERTER_ARGS(z, n, _) \ + typename tuples::element::type \ + /**/ +#define BOOST_LAMBDA_RESULT_CONVERTER(z, n, _) \ + template \ + struct result_converter \ + : result_of< \ + plainF( \ + BOOST_PP_ENUM(n, BOOST_LAMBDA_RESULT_CONVERTER_ARGS, _) \ + ) \ + > \ + {}; \ + /**/ + BOOST_PP_REPEAT( + BOOST_RESULT_OF_NUM_ARGS + , BOOST_LAMBDA_RESULT_CONVERTER + , _ + ) +#undef BOOST_LAMBDA_RESULT_CONVERTER +#undef BOOST_LAMBDA_RESULT_CONVERTER_ARGS + + BOOST_MPL_HAS_TEMPLATE_XXX_TRAIT_NAMED_DEF(has_template_sig, sig, 1, true) + + // we do not know the return type off-hand, we must ask it from Func + // To sig we pass a cons list, where the head is the function object type + // itself (potentially cv-qualified) + // and the tail contains the types of the actual arguments to be passed + // to the function object. The arguments can be cv qualified + // as well. + template + struct sig + : result_converter< + Args + , tuples::length::value + , has_template_sig::value + > + {}; + template static RET apply(A1& a1) { return a1(); Index: 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 --- boost/lambda/detail/lambda_functors.hpp 6 Jul 2006 13:47:26 -0000 1.8 +++ boost/lambda/detail/lambda_functors.hpp 21 Mar 2007 15:36:51 -0000 @@ -13,6 +13,11 @@ #ifndef BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP #define BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP +#include +#include +#include +#include + namespace boost { namespace lambda { @@ -134,6 +139,29 @@ inherited::template sig::type nullary_return_type; + // Support for boost::result_of. +#define BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE(n) \ + typename F::nullary_return_type \ + /**/ +#define BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE(n) \ + typename sig >::type \ + /**/ +#define BOOST_LAMBDA_FUNCTOR_RESULT_TYPE(n) \ + BOOST_PP_IF( \ + n \ + , BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE \ + , BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE \ + )(n) \ + /**/ + BOOST_VARIABLE_ARITY_FUNCTOR_RESULT( + 0 + , BOOST_PP_INC(BOOST_RESULT_OF_NUM_ARGS) + , BOOST_LAMBDA_FUNCTOR_RESULT_TYPE + ) +#undef BOOST_LAMBDA_FUNCTOR_RESULT_TYPE +#undef BOOST_LAMBDA_FUNCTOR_NARY_RESULT_TYPE +#undef BOOST_LAMBDA_FUNCTOR_NULL_RESULT_TYPE + nullary_return_type operator()() const { return inherited::template call Index: 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 --- boost/utility/result_of.hpp 5 Mar 2007 15:25:15 -0000 1.10 +++ boost/utility/result_of.hpp 21 Mar 2007 15:37:14 -0000 @@ -22,6 +22,34 @@ # define BOOST_RESULT_OF_NUM_ARGS 10 #endif +#define BOOST_RESULT_PARTIAL_SPECIALIZATION(z, n, macro) \ + template < \ + class F \ + BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) \ + > \ + struct result { \ + typedef macro(n) type; \ + }; \ + /**/ +#define BOOST_VARIABLE_ARITY_FUNCTOR_RESULT(first, last, macro) \ + template struct result; \ + BOOST_PP_REPEAT_FROM_TO( \ + first, last \ + , BOOST_RESULT_PARTIAL_SPECIALIZATION \ + , macro \ + ) \ + /**/ +#define BOOST_FIXED_ARITY_FUNCTOR_RESULT(n, data) \ + template struct result; \ + template < \ + class F \ + BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) \ + > \ + struct result { \ + typedef data type; \ + }; \ + /**/ + namespace boost { template struct result_of; Index: libs/lambda/test/Jamfile.v2 =================================================================== RCS file: libs/lambda/test/Jamfile.v2 diff -N libs/lambda/test/Jamfile.v2 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libs/lambda/test/Jamfile.v2 21 Mar 2007 15:37:26 -0000 @@ -0,0 +1,45 @@ +# Lambda library + +# Copyright (C) 2001-2007 Jaakko Järvi, Daniel Walker + +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# For more information, see http://www.boost.org/ + +# bring in rules for testing +import testing ; + +test-suite lambda + : + [ run algorithm_test.cpp ] + + [ run bind_tests_simple.cpp ] + + [ run bind_tests_advanced.cpp ] + + [ run bind_tests_simple_f_refs.cpp ] + + [ run bll_and_function.cpp ] + + [ run cast_test.cpp ] + + [ run constructor_tests.cpp ] + + [ run control_structures.cpp ] + + [ run exception_test.cpp ] + + [ run extending_rt_traits.cpp ] + + [ run is_instance_of_test.cpp ] + + [ run member_pointer_test.cpp ] + + [ run operator_tests_simple.cpp ] + + [ run phoenix_control_structures.cpp ] + + [ run switch_construct.cpp ] + ;