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
0
votes
1 answer

How to retrieve file size from range-v3's istream_range?

I'm trying to get file size value from range-v3, like this. std::ifstream i("test.bin", std::ios::binary | std::ios::in); auto rng = ranges::istream_range(i); std::cout << ranges::distance(rng); However it seems that a wrong size is…
sandthorn
  • 2,770
  • 1
  • 15
  • 59
0
votes
1 answer

Why does Op that captures rvalue of std::istringstream by value fails the Accumulateable concept?

This won't compile: auto acc_func = [iss{std::istringstream{}}](int acc, std::string &str) mutable { iss.str(str); int sz; iss >> sz; iss.clear(); return acc + sz; }; ranges::getlines_range lazy_lines =…
sandthorn
  • 2,770
  • 1
  • 15
  • 59
0
votes
1 answer

Why does ranges::accumulate not pass init as std::move(init) when invoke?

As of the commit d5e9afc on Mar 17,2018 of accumulate.hpp When passing a range, the init gets std::move once like this. T operator()(Rng && rng, T init, Op op = Op{}, P proj = P{}) const { return (*this)(begin(rng),…
sandthorn
  • 2,770
  • 1
  • 15
  • 59
0
votes
1 answer

Using a range-v3 view to implement begin()/end() methods

Is it possible to use a view internally to a class in order to implement the begin() / end() methods? For example I want to make the following class iterable; at every iteration op is called on the current element of the two iterables. template…
dvd
  • 1,014
  • 6
  • 12
0
votes
1 answer

Operating over a pointer with ranges

The C++ codebase I'm working on calls a C API that returns both a pointer to a list of structs and the length of the list. What would be the idiomatic means of processing this list with ranges? Is there an existing adapter or is creating a custom…
Tim Clemons
  • 6,231
  • 4
  • 25
  • 23
0
votes
2 answers

Generator take_while based on difference between elements

I'm trying to approximate Hughes functional version of Newton-Raphson square roots algorithm from his 1989 paper "Why Functional Programming Matters". I appreciate any advice for alternative approaches: more is better. My current approach uses…
Timtro
  • 418
  • 5
  • 15
0
votes
1 answer

How to create a view_facade using range-v3

I'm working on a hierarchical Entity-Component System. It's called hierarchical because an Entity might be composed of several Entities. My hierarchy structure is implemented as several linked lists. Although, I'm not relying on several std::list…
csguth
  • 569
  • 3
  • 18
0
votes
1 answer

shuffle action in ranges-v3

Since the ranges-library is up for inclusion into the standard I was toying around with it for a while and I have some problems with very basic concepts. The toy example I am struggling with is this: #include #include…
Richard Vock
  • 1,286
  • 10
  • 23
0
votes
2 answers

How to transform a range, pair-by-pair with range-v3?

I'm writing an algorithm to remove overlaps, given a range of lines (I'm calling it "lines" due to the ambiguity of the term "range" in this case). This is how a line looks like: struct line { int begin, width; int end() const { return begin +…
csguth
  • 569
  • 3
  • 18
-1
votes
1 answer

Don't understand this problem with ranges::v3

I have the following code fragment using ranges::v3: #include #include #include #include #include #include #include…
Nicole
  • 699
  • 1
  • 5
  • 15
-1
votes
2 answers

How to get type of a view?

I want put the definition of a view in a separate compilation unit, but to export the view I need it's type. // .h auto GetView(int index, int size); // .cpp auto GetView(int index, int size) { auto view = ranges::views::ints(-2, 3) |…
Tom Huntington
  • 2,260
  • 10
  • 20
-1
votes
2 answers

Why does ranges-v3 not move elements even the iterator is std::move_iterator?

#include #include #include #include using namespace std::literals; int main() { auto src = std::vector{"123"s, "456"s, "789"s}; auto movable_rng = ranges::subrange( …
xmllmx
  • 39,765
  • 26
  • 162
  • 323
-1
votes
1 answer

Manipulate underlying range with range-v3

I have a mathy library. In this library, I have functions to manipulate hyperplanes in a simplex space, so that I can sort through them in various ways. It turns out that these hyperplanes can represent different things in different contexts. While…
Svalorzen
  • 5,353
  • 3
  • 30
  • 54
1 2 3
20
21