Boost logo

Boost :

Subject: Re: [boost] [iterator] Combining traversal_tags with iterator_tags
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-01-08 18:32:37


On Sun, Jan 8, 2012 at 2:34 PM, Thomas Klimpel
<Thomas.Klimpel_at_[hidden]>wrote:

> Ronald Garcia wrote:
> > In MultiArray I would like use iterator_facade to create an iterator
> that can satisfy
> > random_access_traversal, input_iterator_tag, and output_iterator_tag.
> > [snip]
> > So it looks like passing:
> >
> boost::detail::iterator_category_with_traversal<boost::detail::input_output_iterator_tag,boost::random_traversal_tag>
> >
> > as the CategoryOrTraversal would be what I want.
>
> This is a very good idea. The advantage of this "idea" over my ideas how
> to fix the problem is that you neither need to modify Boost.Iterator, nor
> to "lie" to the compiler. However, I would just declare the required
> iterator_tag class locally, so that you don't depend on implementation
> details of Boost.Iterator:
>
> struct random_access_traversal_input_output_iterator_tag
> : boost::random_access_traversal_tag, std::input_iterator_tag
> {
> operator std::output_iterator_tag() const { return
> std::output_iterator_tag(); }
> };
>
> The attached patch for multi_array/iterator.hpp does exactly that. You
> should be able to apply it directly, without any need to wait for changes
> to Boost.Iterator. Independently, you can still pursue your feature request
> for Boost.Iterator (if you want).
>

I agree, I think the thing to do here is to be explicit about what tag you
want to use, rather than pulling this out of Boost.Iterator's detail
namespace; e.g., the above prefers conversions to std::input_iterator_tag
over std::output_iterator_tag, which could have subtle effects in some
situations.

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk