Ticket #864: djw_lambda_result.patch

File djw_lambda_result.patch, 7.2 KB (added by daniel.j.walker@…, 13 years ago)

The patch file was missing. I am reattaching it.

  • 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
     
    1212#ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
    1313#define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
    1414
     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"
    1519#include "boost/type_traits/same_traits.hpp"
     20#include "boost/utility/result_of.hpp"
    1621
    1722namespace boost {
    1823namespace lambda {
    1924
    2025template <class Func> struct function_adaptor {
    2126
     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
    2260  // 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
    2375  template <class Args> class sig {
    2476    typedef typename Args::head_type F;
    25     typedef typename detail::remove_reference_and_cv<Func>::type plainF;
    2677  public:
    27     // To sig we pass a cons list, where the head is the function object type
    28     // itself (potentially cv-qualified)
    29     // and the tail contains the types of the actual arguments to be passed
    30     // to the function object. The arguments can be cv qualified
    31     // as well.
    3278    typedef typename plainF::template sig<Args>::type type;
    3379  };
     80#endif // BOOST_NO_RESULT_OF
    3481
    3582  template<class RET, class A1>
    3683  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
     
    1313#ifndef BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP
    1414#define BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP
    1515
     16#include <boost/preprocessor/control/if.hpp>
     17#include <boost/preprocessor/repetition/enum_params.hpp>
     18#include <boost/utility/result_of.hpp>
     19
    1620namespace boost {
    1721namespace lambda {
    1822
     
    134138    inherited::template sig<null_type>::type
    135139      nullary_return_type;
    136140
     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
    137164  nullary_return_type operator()() const {
    138165    return inherited::template
    139166      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
     
    2222#  define BOOST_RESULT_OF_NUM_ARGS 10
    2323#endif
    2424
     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
    2553namespace boost {
    2654
    2755template<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
     12import testing ;
     13
     14test-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    ;