A library for C++20 that introduced std::ranges namespace, which consists of rangified algorithms from
Questions tagged [std-ranges]
379 questions
0
votes
0 answers
Reversing Custom Range in cpp20
I've been working on learning a bit about std::ranges. I've built a view, that provides a prefix fold for some operation on the underlying range. However, it is not as general as the other views, as it doesn't seem to be reversible by…

Aditya Jain
- 59
- 6
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
Is it a disadvantage to have "names" coupled due to custom point objects?
As we know, the CPO can use concepts to check the performance requirements(like input type, output type, etc.) of the user-defined function reload that it found. But they can't check the semantics of the user's function, right? Like the following…

zclll
- 77
- 7
0
votes
1 answer
Is it possible to deduce the value type of a range from the range argument?
If you look at standard algorithms like std::ranges::fill and std::ranges::generate, they both seem to use additional parameters to deduce the range value type for their output ranges. E.g. ranges::fill(v, 10) is able to deduce the value type T…

Josie Thompson
- 5,608
- 1
- 13
- 24
0
votes
1 answer
Scaling an input range by minimum in (upcoming) C++23 (using zip_transform and repeat)
In ADSP Podcast Episode 91 (2022-08-19, around 14:30 ... 16:30) Bryce Lelbach and Conor Hoekstra talk about an example application of the (hopefully) upcoming C++23 ranges views zip_transform and repeat: scaling a range of values by the (non-zero)…

René Richter
- 3,839
- 3
- 34
- 42
0
votes
0 answers
Why c++ constrained algorithms are in the ranges namespace?
Ranges in C++20 are not very appetizing for many people who came from less-verbose languages like Python, because typing std::ranges:: is too verbose.
The proposals seem to have own rationales, but what I don't understand are constrained algorithms,…

frozenca
- 839
- 4
- 14
0
votes
3 answers
Combining std::views::take and pop_front pop_back
I can not figure out how to elegantly combine the take with action of removing the taken elements from container.
Consider the following code:
static constexpr int kBatchSize = 4;
void fn(std::deque& vals) {
const auto elems =…

NoSenseEtAl
- 28,205
- 28
- 128
- 277
0
votes
0 answers
g++ compiles but clang does not
I have the following piece of code:
#include
#include
#include
#include
int main()
{
using std::string, std::string_view;
using std::cout, std::endl;
// auto = std::initializer_list
…

FalcoGer
- 2,278
- 1
- 12
- 34
0
votes
0 answers
Cant Use Ranges on VkLayerProperties?
I was trying out C++20 ranges while working on my Vulkan project, I decided I wanted to try to check if a layer was available before the client added it in my builder object.
I set up my layer properties vector like…

The Floating Brain
- 896
- 8
- 24
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
0 answers
How to make user-defined types work on ranges algorithms with operator overloading in c++20?
In general, if I define class:
class A {
public:
A(int x) {
data = x;
}
// Used for min_element()
bool operator<(const A& a) const {
return data < a.data;
}
private:
int…

sungjun cho
- 809
- 7
- 18
0
votes
2 answers
Why can't ranges be used if in a function?
I'm trying to get a range like python like below:
#include
#include
auto Range(double start, double end, double step)
{
if (start <= end) {
auto step_fun = [=](auto x) { return x * step + start; };
auto…

Learning Lin
- 121
- 1
- 7
0
votes
1 answer
How to incrementially concatenate ranges?
Background
What I am trying to do is to implement some classes that represents geometry. Any instance of a geometry class has a method called vertices() that returns a non-owning view of vertices. A geometry class can be expressed in terms of…

Joakim Thorén
- 1,111
- 10
- 17
0
votes
1 answer
error: no matching function for call to ‘take_view(std::stringstream&, long unsigned int)’
I want to extract a maximum of N + 1 strings from a std::stringstream.
Currently, I have the following code (that needs to be fixed):
#include
#include
#include
#include
#include
#include…

digito_evo
- 3,216
- 2
- 14
- 42
0
votes
0 answers
What const views can we not retrieve iterators for?
This is inspired by this question where the author was unable to call ranges::begin() on a const filter_view. The answer states that this is because begin() may alter the internal state of the filter_view.
Are there any other views on which, when…

theejazz
- 41
- 5