2017-07-04 0:49 GMT+02:00 Ion Gaztañaga via Boost
On 03/07/2017 8:41, Andrzej Krzemienski via Boost wrote:
Those Boost iterators provide two distinct tags:
1. STL-conformant *iterator tag* (in the case of zip-iterator it is
I don't think so. The following example:
#include <iostream> #include
#include template<class Iterator> void print_type(Iterator) { std::cout << typeid(typename Iterator::iterator_category).name() << std::endl; }
int main() { const int N=1; int keys[N]; double values[N]; print_type(boost::make_zip_iterator(boost::make_tuple(&keys[0], &values[0]))); return 0; }
prints in MSVC 2017
"struct boost::iterators::detail::iterator_category_with_traversal
" instead of "std::input_iterator_tag". That type inherits from "std::input_iterator_tag" but it's not an standard tag type, so IMHO, it's a non-conforming iterator.
Not necessarily non-conforming. I guess one could come up with such
interpretation, but the Standatd is not really explicit about this. The
most relevant sentence, "`iterator_category` shall be defined to be the
most specific category tag that describes the iterator’s behavior" -- it
could be read as "do not use any tag but these five" or "if you define a
tag for RandomAccessIterator don't defien iterator_category as
forward_iterator_tag".
The example illustrating the intended usage of tags in [std.iterator.tags]
also shows that it works fine with tags inherited from the standard ones.
This additionally seems to be backed up by MSVC implementation of std::prev:
```
// TEMPLATE FUNCTION prev
template<class _BidIt> inline
_BidIt prev(_BidIt _First,
typename iterator_traits<_BidIt>::difference_type _Off = 1)
{ // decrement iterator
* static_assert(is_base_of