[range] Concept check failing with custom C++20 range support
I've been toying around with a pull request that was entered against boost::range to support integration of boost range_v2 and C++20 ranges to see how flexible it would be: https://github.com/boostorg/range/pull/123 I have a need to continue to use boost::any_range in some of our interfaces, but it would be nice to switch to using C++20 ranges under the covers. A lot of it seems to work well with the type definitions from the pull request, but I'm running into an issue with concept check on line 228 or any_iterator_wrapper.hpp specifically when using the transform adaptor. I don't have the same issue with boost::adaptors::transformed. What has me confused is that I think that the result views::transform should be forward traversal, but I'm not really clear on exactly why it is failing. I created a test if anyone wants to play around with it in a compiler and help me understand what is going on: https://godbolt.org/z/1hMsofbrv Switching between the two commented out base_range declarations will get you different results. Here is the code for anyone that just wants to look at it here: #include <boost/range.hpp> #include <boost/range/adaptors.hpp> #include <boost/range/any_range.hpp> #include <ranges> #if 1 namespace boost::range_detail { template< std::ranges::common_range C > struct range_mutable_iterator< C > { typedef std::ranges::iterator_t< C > type; }; template< std::ranges::common_range C > struct range_const_iterator_helper< C > { typedef std::ranges::iterator_t< C const > type; }; } #endif int main() { std::vector<int> vec(5, 0); auto mul2 = [](int i) { return i * 2; }; auto base_range = vec | std::views::transform(mul2); //auto base_range = vec | boost::adaptors::transformed(mul2); boost::any_range<int, boost::forward_traversal_tag> new_range = base_range; }
participants (1)
-
Jared McIntyre