Re: [Boost-bugs] [Boost C++ Libraries] #973: zip_iterator has value_type == reference

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #973: zip_iterator has value_type == reference
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-12 21:20:58


#973: zip_iterator has value_type == reference
---------------------------+------------------------------------------------
  Reporter: anonymous | Owner: witt
      Type: Bugs | Status: new
 Milestone: | Component: iterator
   Version: Boost 1.34.0 | Severity: Problem
Resolution: | Keywords:
---------------------------+------------------------------------------------

Comment (by anonymous):

 Dave asked for a testcase. Here's one:

 {{{#!c++
 #include <boost/iterator/zip_iterator.hpp>
 #include <boost/iterator/iterator_traits.hpp>
 #include <boost/assert.hpp>

 template<typename It> void my_iter_swap(It i1, It i2) {
   typename boost::iterator_value<It>::type tmp = *i1;
   *i1 = *i2;
   *i2 = tmp;
 }

 int main() {
   int i[2] = { 0, 1 };
   my_iter_swap(boost::make_zip_iterator(boost::make_tuple(i+0)),
 boost::make_zip_iterator(boost::make_tuple(i+1)));
   BOOST_ASSERT(i[0] == 1 && i[1] == 0);
 }

 }}}

 And here's a patch against boost 1.52.0 that fixes it. I hereby place it
 in the public domain.
 {{{
 351a352,362
> // Metafunction to obtain the type of the tuple whose element types
> // are the value types of an iterator tuple.
> template<typename IteratorTuple>
> struct tuple_of_value_types
> : tuple_impl_specific::tuple_meta_transform<
> IteratorTuple,
> iterator_value<mpl::_1>
> >
> {
> };
>
 418c429,430
 < typedef reference value_type;
 ---
> typedef typename
> detail::tuple_of_value_types<IteratorTuple>::type value_type;
 }}}

 Now, can we get this fixed? Pretty please?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/973#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC