Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Range-based for loop with intializer_list

9 views
Skip to first unread message

Paul

unread,
Jan 7, 2017, 10:58:42 AM1/7/17
to
I'm stuck on the below question from C++ Primer. Various answers are
available on the web, none of them completely convincing. No, this isn't
homework or anything. I'm just using the book to learn. I'm not a student.
Thanks for your help.

"When you use an initializer_list in a range for would you ever use a reference as the loop control variable? If so, why? If not, why not?"

Paul

Alf P. Steinbach

unread,
Jan 7, 2017, 11:15:14 AM1/7/17
to
The same concerns as when choosing formal argument types, apply.

Biggish thing: pass by reference (usually reference to `const`).

Built-in type: pass by value.



Cheers & hth.,

- Alf
0 new messages