vector<vector<int>> input{ { { 1, 2 },{ 3, 4 } } };
auto result = input | boost::adaptors::transformed([](const auto& _) {return _; });
result.begin()->begin() == result.begin()->end();
If I run this w/ VS2015 with _ITERATOR_DEBUG_LEVEL=2
, then it fires this error in _Compat(const _Myiter& _Right)
:
_DEBUG_ERROR("vector iterators incompatible");
This is important because Flattening iterator uses this comparison in advance_past_empty_inner_containers()
.
What's going on? How do I fix it?
This returns a copy of
_
:[](const auto& _) {return _; }
.I haven't looked into the code, but it wouldn't surprise me at all if the iterator applies the transformation on each dereference, meaning that each time you dereference
result.begin()
(with->
) you get a different copy of the vector. Iterators into different vectors are not comparable with each other.