
On Sun, Jan 8, 2012 at 2:34 PM, Thomas Klimpel <Thomas.Klimpel@synopsys.com>wrote:
In MultiArray I would like use iterator_facade to create an iterator
Ronald Garcia wrote: 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