Ignore:
Timestamp:
Mar 17, 2015, 4:38:36 AM (4 years ago)
Author:
Peter
Message:

refs #803

The std::random_access_iterator promises that iterator provides random
traversal and that reference_type is an lvalue (i.e. not proxy). If
reference_type is a proxy, it is therefore incorrect to tag the
iterator with std::random_access_iterator. To reflect that we do the
following two changes:

1) Container2DIterator now carries tag
boost::random_access_traversal_tag rather than
std::random_access_iterator. This means that in std:: speak a
Container2DIterator is a random access iterator, if reference is an
lvalue and an input iterator otherwise.

2) The BASE of StrideIterator? is no longer required to be a random
access iterator, instead we require random access traversal.
Therefore, StrideIterator? now uses the default tag rather than
std::iterator_traits<BASE>::iterator_category. This means that the
traversal tag is boost::random_access_traversal_tag (as BASE is
required to provide random access traversal), and in std:: speak the
same rule applies as for Container2DIterator.

3) The concept check for Container2D now requires that iterators
::const_iterator, ::const_row_iterator, ::const_column_iterator are
readable iterator (the random access requirement is removed).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/StrideIterator.h

    r2992 r3393  
    2626#include <boost/concept_check.hpp>
    2727#include <boost/iterator/iterator_adaptor.hpp>
     28#include <boost/iterator/iterator_concepts.hpp>
    2829
    2930namespace theplu {
     
    4142     by combining StrideIterator with a reverse_iterator (from
    4243     e.g. std or boost).
     44
     45     Type Requirements:
     46     - \c RandomAccessIterator must be a \readable_iterator
     47     - \c RandomAccessIterator must be a \random_access_traversal_iterator
    4348  */
    4449  template<typename RandomAccessIterator>
    4550  class StrideIterator
    4651    : public boost::iterator_adaptor<StrideIterator<RandomAccessIterator>
    47                                      , RandomAccessIterator
    48                                      , boost::use_default
    49       , typename std::iterator_traits<RandomAccessIterator>::iterator_category>
     52                                     , RandomAccessIterator>
    5053  {
    5154    typedef boost::iterator_adaptor<StrideIterator<RandomAccessIterator>,
    52                                     RandomAccessIterator,
    53                                     boost::use_default,
    54       typename std::iterator_traits<RandomAccessIterator>::iterator_category>
     55                                    RandomAccessIterator>
    5556    super_t;
    5657
     
    6768      : StrideIterator::iterator_adaptor_(), stride_(stride)
    6869    {
    69       BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
     70      using boost_concepts::RandomAccessTraversal;
     71      using boost_concepts::ReadableIterator;
     72      BOOST_CONCEPT_ASSERT((ReadableIterator<RandomAccessIterator>));
     73      BOOST_CONCEPT_ASSERT((RandomAccessTraversal<RandomAccessIterator>));
    7074    }
    7175
Note: See TracChangeset for help on using the changeset viewer.