Reputation: 71
The following trivial code is failing:
#include <vector>
#include <range/v3/all.hpp>
int main()
{
std::vector<int> const v{ 1, 2, 3, 4 };
ranges::any_view<int, ranges::category::bidirectional |
ranges::category::sized> const a{v};
ranges::begin(a);
}
but if remove the constant here:
a { v };
everything is OK. Is it a bug? Or do I not understand the semantics of any_view
.
UPD: This is MSVC 16.9.0 Preview 1.0 compiler.
Upvotes: 2
Views: 460
Reputation: 38508
ranges::begin(a)
invokes
template<typename R>
ranges::_begin_::fn::operator ()(R && r)
that expects modifiable or r-value parameter r
.
a
declared as const a{v}
would call ranges::_begin_::fn::operator ()<const ranges::any_view<...>>(const ranges::any_view<...> && r)
that is not possible since it would bind r-value a
to l-value parameter.
Upvotes: 1