Ranged based for loop to normal loop

Hi, how can I change this ranged based for loop below to a normal for loop itself? I keep getting an error. Thanks!

 
for (const auto& pt : poly.mPoints)
Hello playpro10,

for (? pt = 0; pt < ?; pt++)

Since I have not idea what "poly.mPoints" is defined as I do not know what to put in for the ?s.

To make a guess for (size_t = 0; pt < poly.mPoints.size(); pt++). That is if "poly.mpoints" is a vector.

Really need more input.

Hope that helps,

Andy
1
2
3
4
5
for (auto it = std::begin(poly.mPoints); it != std::end(poly.mPoints); ++it)
{
	const auto& pt	= *it;
	...
}
I keep getting an error.

You did not show what you did nor the error that you got. Therefore, we cannot help you to learn to interpret the error message nor to see where it came from.


Why do you want to change a loop anyway?
Peter, your response made me laugh, because all that does is remove the syntactic sugar :P
(But it's technically a correct answer to this vaguely posed question.)
Last edited on
Topic archived. No new replies allowed.