Open icedream2linxi opened 8 months ago
This is intended behaviour
Unfortunately, it looks like msvc doesn't print the helpful stuff that gcc or clang would in the error message:
/opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/view/view.hpp:127:13: note: candidate function [with Rng = std::vector<int>, ViewFn = ranges::detail::bind_back_fn_<ranges::views::filter_base_fn, (lambda at <source>:16:13)>] has been explicitly deleted
127 | operator|(Rng &&, view_closure<ViewFn> const &) // ******* READ THIS ********
And the referenced code section:
template<typename Rng, typename ViewFn> // **************************
friend constexpr auto // **************************
operator|(Rng &&, view_closure<ViewFn> const &) // ******* READ THIS ********
// **** IF YOUR COMPILE *****
-> CPP_broken_friend_ret(Rng)( // ****** BREAKS HERE *******
requires range<Rng> && // **************************
(!viewable_range<Rng>)) = delete; // **************************
// * When piping a range into an adaptor, the range must satisfy the *
// * "viewable_range" concept. A range is viewable when either or both *
// * of these things are true: *
// * - The range is an lvalue (not a temporary object), OR *
// * - The range is a view (not a container). *
// **************************************************************************
See https://gcc.godbolt.org/z/s58o7bjqT
getAllItems()
returns an rvalue std::vector
, and rv::filter
is a view, ie. non owning
The issue with this code working would be where the rvalue vector would live, what would own it - views are lightweight and don't own containers like this (except cache1 AFAIK) so the filter view can't. Nothing can. | ranges::to<std::vector<int>>();
can be removed and you'll get the same error
As you've alluded to in your code snippet, and the above compile message says, a fix here is to use an lvalue instead
version: 0.12.0 compiler: Visual Studio 2022 x64
code:
error logs: