Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:45:47+00:00 2026-05-25T06:45:47+00:00

For example: v.for_each([](int i) { printf(%d\n, i); }); if far more elegant and readable

  • 0

For example:

v.for_each([](int i) { printf("%d\n", i); }); 

if far more elegant and readable than the commonly-used:

std::for_each(v.begin(), v.end(), [](int i) { printf("%d\n", i); });

Is there a legitimate reason such a member function is missing from the standard?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:45:47+00:00Added an answer on May 25, 2026 at 6:45 am

    This is the standard design rationale for the entire library: Separate containers from algorithms.

    If you did it your way, you’d have to implement every feature X for every container Y, leading you to M * N implementations if you have M features and N containers.

    By using iterators and make algorithms work on iterators rather than containers, you only have to implement M algorithms plus N iterator interfaces.

    This separation also means that you have infinitely wider scope of application: the algorithms cannot just be used for every library container, but for any container, present or future, that anyone decides to write and equip with iterators. Finite vs infinite reuse is quite a strong argument! And calling the algorithms through the generic, free interface doesn’t add any cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder how to label each equation in align environment? For example \begin{align} \label{eq:lnnonspbb}
There are many phones, each with it's own icon size (for example, Nokia has
Lets take qsort()'s comparison callback function as an example int (*compar)(const void *, const
The following example, beats me. I've been so far thinking, that when functor is
static void HandlePackets(void* pParams) { int iResult = 0; char recvbuf[MAX_PACKET_LENGTH]; printf(Packet handling started\n);
Take for example an application which has users, each of which can be in
For example: > function foo() { > jQuery(whatever).each( function() { return; // this just
Some files in our repository are individual to each developer. For example some developers
How do I skew an image? For example, each corner has a CGPoint with
For Example You know foreach loop is heavy And if we use for loop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.