Boost logo

Boost :

Subject: Re: [boost] [iterator] Combining traversal_tags with iterator_tags
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2012-01-08 17:34:35

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).


Boost list run by bdawes at, gregod at, cpdaniel at, john at