Ticket #8608: default_lambda_args.diff

File default_lambda_args.diff, 6.1 KB (added by Louis Dionne <ldionne.2@…>, 9 years ago)

Test case, code fix and documentation change.

  • trunk/boost/mpl/equal.hpp

    diff --git a/trunk/boost/mpl/equal.hpp b/trunk/boost/mpl/equal.hpp
    a b  
    44
    55// Copyright Aleksey Gurtovoy 2000-2004
    66//
    7 // Distributed under the Boost Software License, Version 1.0. 
    8 // (See accompanying file LICENSE_1_0.txt or copy at 
     7// Distributed under the Boost Software License, Version 1.0.
     8// (See accompanying file LICENSE_1_0.txt or copy at
    99// http://www.boost.org/LICENSE_1_0.txt)
    1010//
    1111// See http://www.boost.org/libs/mpl for documentation.
     
    1414// $Date$
    1515// $Revision$
    1616
     17#include <boost/mpl/always.hpp>
     18#include <boost/mpl/and.hpp>
     19#include <boost/mpl/apply.hpp>
     20#include <boost/mpl/aux_/iter_apply.hpp>
    1721#include <boost/mpl/aux_/iter_fold_if_impl.hpp>
    18 #include <boost/mpl/aux_/iter_apply.hpp>
    19 #include <boost/mpl/and.hpp>
    20 #include <boost/mpl/not.hpp>
     22#include <boost/mpl/aux_/lambda_support.hpp>
     23#include <boost/mpl/aux_/msvc_eti_base.hpp>
     24#include <boost/mpl/aux_/na_spec.hpp>
    2125#include <boost/mpl/begin_end.hpp>
    22 #include <boost/mpl/next.hpp>
    23 #include <boost/mpl/always.hpp>
     26#include <boost/mpl/bind.hpp>
    2427#include <boost/mpl/bool.hpp>
    2528#include <boost/mpl/lambda.hpp>
    26 #include <boost/mpl/bind.hpp>
    27 #include <boost/mpl/apply.hpp>
     29#include <boost/mpl/next.hpp>
     30#include <boost/mpl/not.hpp>
     31#include <boost/mpl/quote.hpp>
    2832#include <boost/mpl/void.hpp>
    29 #include <boost/mpl/aux_/na_spec.hpp>
    30 #include <boost/mpl/aux_/lambda_support.hpp>
    31 #include <boost/mpl/aux_/msvc_eti_base.hpp>
    3233
    3334#include <boost/type_traits/is_same.hpp>
    3435
     
    4950        >
    5051    struct apply
    5152    {
    52         typedef typename and_< 
     53        typedef typename and_<
    5354              not_< is_same<Iterator1,LastIterator1> >
    5455            , not_< is_same<Iterator2,LastIterator2> >
    5556            , aux::iter_apply2<Predicate,Iterator1,Iterator2>
     
    8788
    8889    typedef typename result_::type type;
    8990};
    90 
    91 
    9291} // namespace aux
    9392
    9493
    9594template<
    9695      typename BOOST_MPL_AUX_NA_PARAM(Sequence1)
    9796    , typename BOOST_MPL_AUX_NA_PARAM(Sequence2)
    98     , typename Predicate = is_same<_,_>
     97    , typename Predicate = quote2<is_same>
    9998    >
    10099struct equal
    101     : aux::msvc_eti_base< 
     100    : aux::msvc_eti_base<
    102101          typename aux::equal_impl<Sequence1,Sequence2,Predicate>::type
    103102        >::type
    104103{
    105     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,equal,(Sequence1,Sequence2))
     104    BOOST_MPL_AUX_LAMBDA_SUPPORT(3,equal,(Sequence1,Sequence2))
    106105};
    107106
    108 BOOST_MPL_AUX_NA_SPEC(2, equal)
     107BOOST_MPL_AUX_NA_SPEC(3, equal)
    109108
    110109}}
    111110
  • trunk/libs/mpl/doc/src/refmanual/equal.rst

    diff --git a/trunk/libs/mpl/doc/src/refmanual/equal.rst b/trunk/libs/mpl/doc/src/refmanual/equal.rst
    a b  
    77--------
    88
    99.. parsed-literal::
    10    
     10
    1111    template<
    1212          typename Seq1
    1313        , typename Seq2
    14         , typename Pred = is_same<_1,_2>
     14        , typename Pred = quote2<is_same>
    1515        >
    1616    struct equal
    1717    {
     
    2323Description
    2424-----------
    2525
    26 Returns a true-valued |Integral Constant| if the two sequences ``Seq1`` 
     26Returns a true-valued |Integral Constant| if the two sequences ``Seq1``
    2727and ``Seq2`` are identical when compared element-by-element.
    2828
    2929
     
    3131------
    3232
    3333.. parsed-literal::
    34    
     34
    3535    #include <boost/mpl/equal.hpp>
    3636
    3737
     
    5656
    5757.. parsed-literal::
    5858
    59     typedef equal<s1,s2,pred>::type c; 
     59    typedef equal<s1,s2,pred>::type c;
    6060
    6161:Return type:
    6262    |Integral Constant|
    6363
    6464:Semantics:
    65     ``c::value == true`` is and only if ``size<s1>::value == size<s2>::value`` 
    66     and for every iterator ``i`` in |begin/end<s1>| ``deref<i>::type`` is identical to 
     65    ``c::value == true`` is and only if ``size<s1>::value == size<s2>::value``
     66    and for every iterator ``i`` in |begin/end<s1>| ``deref<i>::type`` is identical to
    6767
    6868    .. parsed-literal::
    6969
     
    7373Complexity
    7474----------
    7575
    76 Linear. At most ``size<s1>::value`` comparisons. 
     76Linear. At most ``size<s1>::value`` comparisons.
    7777
    7878
    7979Example
    8080-------
    8181
    8282.. parsed-literal::
    83    
     83
    8484    typedef vector<char,int,unsigned,long,unsigned long> s1;
    8585    typedef list<char,int,unsigned,long,unsigned long> s2;
    86    
     86
    8787    BOOST_MPL_ASSERT(( equal<s1,s2> ));
    8888
    8989
  • trunk/libs/mpl/test/Jamfile.v2

    diff --git a/trunk/libs/mpl/test/Jamfile.v2 b/trunk/libs/mpl/test/Jamfile.v2
    a b  
    1717compile bind.cpp ;
    1818compile bitwise.cpp ;
    1919run bool.cpp ;
     20compile bug_equal_default_lambda.cpp ;
    2021compile comparison.cpp ;
    2122compile contains.cpp ;
    2223compile copy.cpp ;
  • new file trunk/libs/mpl/test/bug_equal_default_lambda.cpp

    diff --git a/trunk/libs/mpl/test/bug_equal_default_lambda.cpp b/trunk/libs/mpl/test/bug_equal_default_lambda.cpp
    new file mode 10644
    - +  
     1// Copyright Louis Dionne 2013
     2//
     3// Distributed under the Boost Software License,Version 1.0.
     4// (See accompanying file LICENSE_1_0.txt or copy at
     5// http://www.boost.org/LICENSE_1_0.txt)
     6//
     7// See http://www.boost.org/libs/mpl for documentation.
     8
     9
     10// Test case for the bug reported at:
     11// https://svn.boost.org/trac/boost/ticket/8608
     12
     13
     14#include <boost/mpl/assert.hpp>
     15#include <boost/mpl/equal.hpp>
     16#include <boost/mpl/find_if.hpp>
     17#include <boost/mpl/placeholders.hpp>
     18#include <boost/mpl/vector.hpp>
     19#include <boost/type_traits/is_same.hpp>
     20
     21
     22using namespace boost;
     23using namespace boost::mpl;
     24
     25
     26template <typename VectorOfVectors, typename Vector>
     27struct find_vector
     28    : find_if<
     29        VectorOfVectors, equal<Vector, _1>
     30    >
     31{ };
     32
     33typedef find_vector<
     34    vector<
     35        vector<int, int>,
     36        vector<char, char>
     37    >,
     38    vector<char, char>
     39>::type ThisShouldNotBreak;