https://www.boost.org/doc/libs/1_85_0/libs/iterator/doc/transform_iterator.html says it typedefs iterator_category based on the underlying iterator. However, nothing in https://github.com/boostorg/iterator/blob/develop/include/boost/iterator/transform_iterator.hpp seems to indicate that it's doing so.
With llvm/llvm-project#112102 disallowing std::prev(non_cpp17_bidi_iterator), we have code that breaks due to transform_iterator not being bidi even though the underlying iterator is.
Example: https://godbolt.org/z/a6TzjGW91
#include <iostream>
#include <boost/iterator/transform_iterator.hpp>
int main() {
auto d = [](int i) { return i * 2; };
int a[] = {1, 2, 3};
auto begin = boost::make_transform_iterator(std::begin(a), d);
auto end = boost::make_transform_iterator(std::end(a), d);
static_assert(std::bidirectional_iterator<decltype(std::begin(a))>);
static_assert(std::bidirectional_iterator<decltype(begin)>); // this fails
for (auto i = begin; i != end; ++i) {
std::cout << *i << " ";
}
}
adding something like using iterator_category = std::iterator_traits<Iterator>::iterator_category; around
seems to fix this for the case we ran into.
https://www.boost.org/doc/libs/1_85_0/libs/iterator/doc/transform_iterator.html says it typedefs
iterator_categorybased on the underlying iterator. However, nothing in https://github.com/boostorg/iterator/blob/develop/include/boost/iterator/transform_iterator.hpp seems to indicate that it's doing so.With llvm/llvm-project#112102 disallowing std::prev(non_cpp17_bidi_iterator), we have code that breaks due to
transform_iteratornot being bidi even though the underlying iterator is.Example: https://godbolt.org/z/a6TzjGW91
adding something like
using iterator_category = std::iterator_traits<Iterator>::iterator_category;arounditerator/include/boost/iterator/transform_iterator.hpp
Line 93 in 4b40364