Opened 13 years ago

Closed 12 years ago

#3204 closed Bugs (fixed)

binary mpl::transform fails to compile with fusion::vector

Reported by: tegtmeye@… Owned by: Joel de Guzman
Milestone: Boost 1.44.0 Component: fusion
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc:

Description

Comments from boost-users mailing list:

<quote>

Trying the code, it seems mpl::(binary)transform is looking for Seq::tag which is not a requirement for MPL::Forward Sequence which mpl::transform requires (http://tinyurl.com/l6kcb4). fusion::vector adheres fully to an MPL::Forward Sequence.

No, the error is caused by the following code in MPL's pair_view (which is the underlying implementation mechanism for the binary transform):

typedef typename min<

typename iterator_category<iter1_>::type

, typename iterator_category<iter2_>::type

::type category_;

That is, as per iterator_category's requirements [1], pair_view assumes that the iterator_category's result would be model of MPL's Integral Constant, which does not seem to be the case with Fusion categories.

[1] http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc/refmanual/iterator-categor y.html </quote>

The following code fails to compile:

#include <boost/mpl/transform.hpp>
#include <boost/mpl/vector.hpp>

#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/container/vector.hpp>

#include <utility>

using namespace boost;

struct my_make_pair {
  template<typename T1, typename T2>
  struct apply {
    typedef std::pair<T1,T2> type;
  };
};

int main(int argc, char *argv[])
{
#if 0
  typedef mpl::vector<int,long> seq1;
  typedef mpl::vector<float,double> seq2;
  typedef mpl::vector<std::pair<int,float>,std::pair<long,double> > pairs;

  typedef mpl::transform<seq1,seq2,my_make_pair>::type result;

  BOOST_MPL_ASSERT(( equal<result,pairs> ));
#endif


  typedef fusion::vector<int,long> seq1;
  typedef fusion::vector<float,double> seq2;
  typedef fusion::vector<std::pair<int,float>,std::pair<long,double> >
pairs;

  typedef mpl::transform<seq1,seq2,my_make_pair>::type result;

  BOOST_MPL_ASSERT(( equal<result,pairs> ));


  return 0;
}

Change History (3)

comment:1 by tegtmeye@…, 12 years ago

Milestone: Boost 1.40.0Boost 1.44.0

Still present in 1.43

comment:3 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: newclosed

(In [62889]) Translate fusion iterator categories to MPL iteraotr categories for fusion_iterator. Fixes #3204.

Note: See TracTickets for help on using tickets.