Category : range-v3

Consider the following code snippet: #include <ranges> int main() { auto r = std::views::iota(0) | std::views::take(0); static_assert(std::ranges::sized_range<decltype(r)>); } gcc-trunk rejects it for required-expression std::ranges::size(r) is invalid. Why does r not model ranges::sized_range, i,e, why can’t I use std::ranges::size on it? Update Compiles after using range-v3. Is this feature required for C++23, or is it an ..

Read more

In [range.subrange.general], the subrange‘s constructor only take the range or iterator which should satisfy the convertible-to-non-slicing concept as an argument, and the convertible-to-non-slicing concept defines like this: template<class From, class To> concept convertible-to-non-slicing = // exposition only convertible_­to<From, To> && !(is_pointer_v<decay_t<From>> && is_pointer_v<decay_t<To>> && not-same-as<remove_pointer_t<decay_t<From>>, remove_pointer_t<decay_t<To>>>); What is the purpose of this concept, and what ..

Read more

I have a pair of iterator, and I would like to use ranges::views::filter(some_predicate) on it (with the pipe operator). AFAIU I should first convert my pair of iterator into a view. I tried to use ranges::subrange(first, last) to do so, but I’m getting horrible error messages. Note1: I’m using C++14 and range-v3 version 0.9.1 (the ..

Read more

Consider the following code: #include <ranges> int main() { constexpr int a[] = {1, 2, 3, 4}; constexpr auto r = a | std::views::take(3); static_assert(*r.begin() == 1); } msvc accept it, gcc rejects it with: <source>:5:44: error: ‘std::ranges::take_view<std::ranges::ref_view<const int [4]> >{3, std::ranges::ref_view<const int [4]>{(& a)}}’ is not a constant expression 5 | constexpr auto r ..

Read more

I have a simple test class Span that is iterable, returning elements also of type Span, via a SpanIter. I would like to use range-v3 pipes, but I don’t understand the requirements. Span is iterable with standard c++11 autos, but not range-v3. The class definitions and test code are below. Beyond "what is wrong", I ..

Read more