range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

ranges::view::all & concepts viewable_range are different with std::ranges

Open JYLeeLYJ opened this issue 2 years ago • 3 comments

Hello , today I found that ranges::view::all cannot accept a prvalue range. For example , R = std::vector<int> is not a ranges::viewable_range.

But the same usage with std::ranges is ok , which shows difference with range-v3 . According to range.all , all(std::vector<int>()) should be correct ( it is an owning_view in std::ranges ) . It is actually "viewable" .

(same code on godbolt)

#include <range/v3/view.hpp>

#include <ranges>
#include <vector>

void foo(){
    auto v1 = ranges::view::all(std::vector<int>());    // error
    auto v2 = std::ranges::views::all(std::vector<int>()); // std is ok , which gets an owning_view

    static_assert(std::ranges::viewable_range<std::vector<int>>);   // true
    static_assert(ranges::viewable_range<std::vector<int>>);  // false
}

Does we need to ensure any consistency between range-v3 & std::ranges ?

JYLeeLYJ avatar Jul 18 '22 15:07 JYLeeLYJ

Yeah, range-v3 doesn't implement P2415 yet.

brevzin avatar Jul 18 '22 16:07 brevzin

Thanks for reply ! Is there any plan to implement P2415 in future versions ?

Yeah, range-v3 doesn't implement P2415 yet.

JYLeeLYJ avatar Jul 20 '22 08:07 JYLeeLYJ

consistency with C++20 would be nice and owning_view would be a nice addition

eroller avatar Sep 29 '23 19:09 eroller