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

compile error when trying to use pointer-to-member function as projection to ranges::find()

I want to search an input range for an element that has a certain value in a member via an accessor. range-v3 documentation is... thin, but there are sources such as this answer by AFAIK the 2 main range-v3 developers indicates this kind of thing…
underscore_d
  • 6,309
  • 3
  • 38
  • 64
0
votes
2 answers

understanding how zip in range-v3 works

I am trying to understand how ranges::views::zip works in range-v3. I understand that it is a range that allows to iterate on several ranges in one single loop by creating a tuple of the elements in different ranges. std::vector v1 = {0, 1,…
jjcasmar
  • 1,387
  • 1
  • 18
  • 30
0
votes
1 answer

Remove duplicates in two vector based on duplicates on first vector

I have two vector that are related. The vector have the same size and their content match 1:1 in the sense that it could be refactores into a single vector of some struct. I am trying to remove the duplicates on the first vector, and this should…
jjcasmar
  • 1,387
  • 1
  • 18
  • 30
0
votes
1 answer

How to use range-v3's ranges::actions::transform?

I want to use ranges-v3 to transform an array in place. I can use ranges::transform successfully, but failed to use actions::transform. int arr[]{1, 2, 3}; auto fn = [](auto e) { return e + 1; }; ranges::transform(arr, std::begin(arr), fn); //…
xmllmx
  • 39,765
  • 26
  • 162
  • 323
0
votes
1 answer

Filtered range (circular) traversal starting from iterator over original sequence

Say you have a container and have an iterator to some element of that container. The requirement is to circularly advance that iterator but with a filter. Now, creating a filtered (circular) view over the sequence is trivial but how do you initiate…
Engineerist
  • 367
  • 2
  • 13
0
votes
0 answers

remove suffix of strings in range v3

I am splitting two strings into std::vector's by whitespace, remove duplicates and sort them. Afterwards I would like to join each vector to one continous range with a whitespace as delimiter. Using ranges v3 this works by using views::join('…
maxbachmann
  • 2,862
  • 1
  • 11
  • 35
0
votes
0 answers

not a constant expression in ranges-v3

I am having an issue compiling a project which uses ranges-v3. It complains an expression, which to me looks constant, is not constant. [ 47%] Building CXX object src/foo.cpp.o In file included from…
jjcasmar
  • 1,387
  • 1
  • 18
  • 30
0
votes
1 answer

Can't find any functions in ranges::view namespace

2 weeks ago I asked some questions and I haven't found a solution yet. I'm using visual studio 2019 and I installed range-v3 library via vcpkg. I know vcpkg version is not latest, but is it really different from latest version? I only found some…
Orcinus
  • 11
  • 2
0
votes
2 answers

i can't import range-v3 library via vcpkg

i found range-v3 library and i was trying to follow examples in https://ericniebler.github.io/range-v3/index.html i'm using visual studio 2019 and i installed range-v3 library via vcpkg but... i can't find any functions in ranges::views nameaspace.…
Orcinus
  • 11
  • 2
0
votes
0 answers

Mutate Element of Range View

I have a 2-dimensional vector of enums std::vector>, the enum can have the values a (0), b (1), c(2). I would like to randomly set one of the a's to c and thought I'll try out the ranges library. Currently I have a view of all the…
DenverCoder21
  • 879
  • 3
  • 16
  • 34
0
votes
0 answers

How do I get write access to the underlying vector entries of a range-v3 view and assign values of another view to it?

Having a matrix stored in a vector of row-major order, I want to get write access to a column-view (to the corresponding vector entries). Is it possible to somehow dereference a range-v3 column-view and directly assign the values of another view to…
Porsche9II
  • 629
  • 5
  • 17
0
votes
1 answer

How to store a range as a field in a class?

I would like to store a range as a field in a class, so that I could reuse it several times later on. However, unlike local variables, I cannot simply specify it type as auto. On the other hand, the types of ranges that the library creates are very…
CygnusX1
  • 20,968
  • 5
  • 65
  • 109
0
votes
1 answer

ranges-v3 access cursor internals

In c++ range-v3 library. Is it possible to access cursor's (from view_facade) internal data? class range_t : public ranges::view_facade { friend ranges::range_access; struct cursor { cursor() = default; …
tower120
  • 5,007
  • 6
  • 40
  • 88
0
votes
1 answer

return different range constructs from function

I try to get range views that behave like true-false masks. To do logical operations I want to implement ands and ors of masks. I have a working compile time or: struct make_or_mask_fn { template auto operator()(Msks&&...…
pseyfert
  • 3,263
  • 3
  • 21
  • 47
0
votes
0 answers

Explain for loop over tuples

In range-v3 the following is legal code for c++17. CardDeck::CardDeck() { std::vector Suits = {Clubs, Diamonds, Hearts, Spades}; std::vector Values = {Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King,…
1 2 3
20
21