Foreach loop: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by Abductive | #UCB_webform 583/2200
DarthKitty (talk | contribs)
m C++: remove unnecessary lambda captures
Line 216:
std::vector<int> v {1, 2, 3, 4, 5};
 
std::for_each(v.begin(), v.end(), [&](int i)
{
std::cout << i << '\n';
Line 223:
std::cout << "reversed but skip 2 elements:\n";
 
std::for_each(v.rbegin()+2, v.rend(), [&](int i)
{
std::cout << i << '\n';