Questions tagged [range-v3]

range-v3 is a range library for C++14/17/20.

range-v3 is a range library for C++14/17/20. It is the basis of a formal proposal (N4128 Ranges for the Standard Library) to add range support to the C++ standard library. It also is the reference implementation for a Technical Specification (N4560 Working Draft, C++ extensions for Ranges). Source is available on Github.

313 questions
1
vote
1 answer

ranges v3 any_view & constant

The following trivial code is failing: #include #include int main() { std::vector const v{ 1, 2, 3, 4 }; ranges::any_view
Serge Kork
  • 61
  • 3
1
vote
1 answer

What is the correct way of filtering the output of group_by with Range-v3?

The following code does not compile because x cannot be compared with a std::vector, as x is a more complex structure handled by Range-v3 (which is good, because it's lazy, unlike std::vector). How can I write the filtering lambda to cope…
Enlico
  • 23,259
  • 6
  • 48
  • 102
1
vote
2 answers

Difference between `closed_iota` and `iota`?

What is the difference between closed_iota and iota, from the ranges-v3 library?
1
vote
0 answers

Lazy Math with C++ Ranges

I wanted to explore the realm of lazy mathematical operations in c++ using ranges (specifically range-v3), rather than expression templates. Instead of defining the various operators :operator+, operator-, ... and so on, to accept all ranges, I…
ptb
  • 2,138
  • 1
  • 11
  • 16
1
vote
1 answer

Range trim view implementation does not work with reverse view

I wrote a C++20 range view (not a range-v3 view) called trim that, given a range and a unary predicate, returns a new range without the front and back elements that satisfy the predicate. (The range-v3 library has such a view, but it's missing from…
Marius Bancila
  • 16,053
  • 9
  • 49
  • 91
1
vote
0 answers

C7608: atomic constraint should be a constant expression when using ranges::to_vector

Edit : I posted an issue on the range-v3 GitHub So, I'm trying to use the range-v3 library. But when I compile my code, it stops with the error C7608. Here's a relevant snippet: #include "json/single_include/nlohmann/json.hpp" #include…
G'k
  • 66
  • 1
  • 7
1
vote
2 answers

When are ranges::views calculated at compile time?

The range-v3 library allows the use of views, which enable lazy operations on data. From what I know, lazy operations are only possible when a function is evaluated at compile time, but to achieve a compile time calculation, the code must be in a…
M.Mac
  • 699
  • 3
  • 14
1
vote
1 answer

Get range-v3 intersection of vector of pairs

I want to get an intersection of two vectors of pairs. I can do it with the stl which uses the default comparator (? - correct me if I word it wrong). std::vector> pathWire1 = {{1,1}, {2,2}, {3,3}}; std::vector
Rafal
  • 129
  • 2
  • 9
1
vote
1 answer

Using ranges-v3 to implement DFS

I'm interested in using range-v3 to build and query linear quadtree data structures. I've been able to successfully use range-v3 to construct a linear quadtree data structure using existing views in the library. I'm excited to be able to express…
Stefan Novak
  • 763
  • 1
  • 6
  • 13
1
vote
1 answer

range-v3: strange Behavior

I am trying to play with range-v3 and I encountered a problems : it does not extract values from a vector as I would have wanted. See the code below: When running, it outputs (0, 0), instead of what I would have thought, i.e (1, 0) If I uncomment…
Pascal T.
  • 3,866
  • 4
  • 33
  • 36
1
vote
0 answers

write to a zipped back inserted ranges

A close cousin of this other question, but with back_inserter: #include #include #include // ... std::vector< std::tuple > const data{ {1,"a",…
Nick
  • 931
  • 6
  • 17
1
vote
1 answer

writable zip ranges are not possible?

The following is failing: #include #include #include // ... std::vector< std::tuple > const data{ {1,"a"}, {2,"b"}, {3,"c"} }; std::vector
Nick
  • 931
  • 6
  • 17
1
vote
1 answer

Is there a way to have read-and-write views in Range-v3?

In Range-v3 one can easily create view of existing containers. For example #include #include int main(){ std::vector v = {1,2,3}; auto range = v | ranges::v3::view::transform([](auto x){return…
alfC
  • 14,261
  • 4
  • 67
  • 118
1
vote
0 answers

How does the implementation of range-v3's meta::defer work?

Here is the implementation of meta::defer: template