Unknown Operator

Jun 27, 2017 at 1:01pm
Hi everybody,

I was looking at some code and I noticed the following line:

 
for (auto ch : _params.ch)


What does the ':' operator mean in this case? I have never seen it used with the auto operator.

Thanks.
Jun 27, 2017 at 1:12pm
See Range-based for loop here:
http://www.cplusplus.com/doc/tutorial/control/
Jun 27, 2017 at 1:13pm
That is not an operator. It is range-syntax of for-loop that was introduced in C++11.
http://en.cppreference.com/w/cpp/language/range-for

Note that before C++11 the auto was a storage class specifier
http://en.cppreference.com/w/cpp/language/storage_duration

but since C++11 it does type deduction
http://en.cppreference.com/w/cpp/language/auto
Jun 27, 2017 at 1:20pm
Thank you to both of you!
Topic archived. No new replies allowed.