ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.06k stars 437 forks source link

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

Open JYLeeLYJ opened 1 year ago

JYLeeLYJ commented 1 year ago

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 ?

brevzin commented 1 year ago

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

JYLeeLYJ commented 1 year ago

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

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

eroller commented 9 months ago

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