ranged-loops Questions

12

Solved

Is there a container adapter that would reverse the direction of iterators so I can iterate over a container in reverse with range-based for-loop? With explicit iterators I would convert this: fo...
Armipotent asked 17/12, 2011 at 4:29

2

So, I decided I want to use an mdspan rather than a combination of plain span + element access function. But - one obvious thing I want to do with my mdspan is iterate its elements. This is how I w...
Elena asked 18/3, 2023 at 22:21

1

Solved

There are a number of different ways, that make a type/class usable in a ranged for loop. An overview is for example given on cppreference: range-expression is evaluated to determine the sequence ...
Chrisoula asked 14/4, 2022 at 8:14

1

Solved

I wrote a c++ function that assembles some data then then returns a std::shared_ptr to a newly allocated std::vector containing the data. Something analogous to this: std::shared_ptr<std::vecto...
Scrawly asked 30/4, 2018 at 3:46

8

Solved

I'm having a little bit of trouble with the ranged for in C++. I'm trying to used it to display the element on and int array (int[]) and it works completely fine when I do that on the main function...
Antonetteantoni asked 24/11, 2016 at 16:35

2

Solved

The C++11 introduced ranged-based for loop that is internally implemented using (const) iterators so this: std::vector<std::string> vec; for(std::string &str : vec) { //... } is basic...
Lactoscope asked 11/10, 2016 at 15:22

8

Solved

I found myself writing this just a bit ago: template <long int T_begin, long int T_end> class range_class { public: class iterator { friend class range_class; public: long int operator ...
Orosco asked 25/8, 2011 at 5:12

4

Solved

I'm getting dangling references while using a ranged-for loop. Consider the following C++14 expression (full example program below): for(auto& wheel: Bike().wheels_reference()) wheel.inflate...
Klepht asked 14/1, 2016 at 11:53

1

Before replacing a lot of my "old" for loops with range based for loops, I ran some test with visual studio 2013: std::vector<int> numbers; for (int i = 0; i < 50; ++i) numbers.push_back...
Joust asked 15/11, 2014 at 1:13
1

© 2022 - 2024 — McMap. All rights reserved.