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
0 answers

Range-v3 ranges::to operator custom class (container)

I have list of messages and I need to convert to Json them. And now I use this solution; Bu I see to<> function. This function generic and I can use vector (iterator) But how can use custom Adapter? My solution: vector messages =…
0
votes
1 answer

Transpose vector of vectors with views::zip

Duplicate: https://stackoverflow.com/a/61819663/11998382 This should be possible if we know the size of the outer vector at compile time. You just have to write the c++ variadic-template equivalent of the following python code: def…
Tom Huntington
  • 2,260
  • 10
  • 20
0
votes
1 answer

What is range/v3/functional/comparisons.hpp for?

What is this header for? It defines, just to give an example, equal_to: namespace ranges { /// \addtogroup group-functional /// @{ struct equal_to { template(typename T, typename U)( /// \pre requires…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
2 answers

Using range::find on a view

I'd like to rangify the following code, which checks for the first occurance of a sequence of unique characters: bool hasOnlyUniqueElements( auto& data ) { std::unordered_set set; for( auto& value : data ) set.emplace( value…
Grimkin
  • 107
  • 5
0
votes
1 answer

concept error: satisfaction of atomic constraint '....' depends on itself

I am using the following concepts to identify a map-like type, but it causes a cryptic error within the range-v3 v.0.12 library when used with GCC-11 or GCC-12 on linux: template < typename MapLike > concept mapping = requires(MapLike m) { …
Michael A
  • 151
  • 1
  • 7
0
votes
1 answer

Ranges-v3 transform limitations

I am trying to use ranges-v3 to split an SNMP OID into parts and return them as a std::deque. The following code works but only after I added a number of additional un-natural steps: #include /// split the supplied…
mark
  • 7,381
  • 5
  • 36
  • 61
0
votes
1 answer

Is range to tuple conversion possible?

I'm trying to parse a Wavefront OBJ file. If line describes a vertex, i try to split it, take XYZ-coordinates, and assign them to a tuple. For example, if the line is "v -0.000581696 -0.734665 -0.623267 1.0", the result must be {-0.000581696,…
henker
  • 1
  • 1
0
votes
1 answer

ranges::views::generate have generator function signal end of range

I'd like to have a generator that terminates, like python, but I can't tell from ranges::views::generate's interface if this is supported.
Tom Huntington
  • 2,260
  • 10
  • 20
0
votes
1 answer

How can I read a 2-columns CSV file into a map with ranges?

I'm given a CSV file with two elements per line: 1,2 12,40 11,7 ... which I want to read into a std::map. How can I do that, using anything from Ranges library and Range-v3? At the moment this is where I've got (with the help of this…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
1 answer

How to iterate over a range-v3 action?

I'm new to range-v3. I started by write a program that generates a range of integers, modifies it, and prints out the resulting range. I used a modifier from the actions library, which rendered my code non-iterable. Could someone help me understand…
Piotr Trochim
  • 693
  • 5
  • 15
0
votes
1 answer

Does range-v3's "sliding" view not work with lazy ranges?

I don't understand why the following code does not compile while the commented out version does work. #include #include namespace rv = ranges::views; int main() { //std::vector fives =…
jwezorek
  • 8,592
  • 1
  • 29
  • 46
0
votes
1 answer

Range-v3: How to use actions::insert with a map

I've seen this example question on how to use ranges::actions::insert with a vector but I couldn't get it working with a map container. Would someone show me how to use it in this case, please? I'm trying, using the ranges actions::insert function…
Andrew
  • 626
  • 6
  • 16
0
votes
1 answer

Range-v3, how to access a range of a range value individually (group_by function)

I'm using range-v3 by Eric Niebler and using the ranges::views::group_by function. In the documentation for group_by it says: "Given a source range and a binary predicate, return a range of ranges where each range contains contiguous elements from…
Andrew
  • 626
  • 6
  • 16
0
votes
1 answer

Concatenate range of ranges to range

Let rw = ranges::views. I'm trying to create exclusively using range-v3 an analog of the construction: std::vector v; // range = {0, 1, 2} auto range = rw::ints (0, 3); for (int i : range) for (int j : range) v.push_back (func (i,…
Alexey Ismagilov
  • 187
  • 2
  • 11
0
votes
1 answer

Using range-v3 with rvalue returned by cgal

I want to use range-v3 to enumerate a range. The range is produce by CGAL using the CGAL::Surface_mesh::faces() function, which returns a range for the faces in the mesh. However, range-v3 can't attach views to an rvalue range, so I can't…
jjcasmar
  • 1,387
  • 1
  • 18
  • 30