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

  • SEARCH
  • Home
  • 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 8843757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:18:43+00:00 2026-06-14T11:18:43+00:00

So since it was introduced I have been loving the for each in keywords

  • 0

So since it was introduced I have been loving the for each in keywords to iterate STL collections.(I’m a very very big fan of syntactic sugar).

My question is how can I write a custom collection that can be iterated using these keywords?

Essentially, what APi do I need to expose for my collections to be iterable using these keywords?

I apologize if this sounds blunt, but please do not respond with “use boost”, “don’t write your own collections”, or the like. Pursuit of knowledge, my friends. If it’s not possible, hey, I can handle that.

I’d also very much so prefer not to have to inject an STL iterator into my collections.

Thanks in advance!

  • 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-06-14T11:18:45+00:00Added an answer on June 14, 2026 at 11:18 am

    Here is a good explanation of iterable data structures (Range-Based loops):

    In order to make a data structure iterable, it must work similarly to the existing STL iterators.

    1. There must be begin and end methods that operate on that structure,
      either as members or as stand-alone functions, and that return iterators to
      the beginning and end of the structure.
    2. The iterator itself must support an operator* method, an operator != method, and an operator++ method, either as members or as stand-alone functions.

    Note, in C++11 there is an integrated support for range-based loops without the use of STL, though the above conditions hold for this as well. You can read about it at the same link above.

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

Sidebar

Related Questions

I have been using WinForms since the first framework introduced and invested a lot
I have an app that uses OnDragListener . Since this has been introduced only
Ever since Adobe introduced ActionScript 3 with Flash Player 9, many of us have
Well I have been thinking about this for a while, ever since I was
I have a lot of multithreading bugs since I introduced a second worker thread.
Since Django 1.3 the concept of STATIC_URL has been introduced to separate use media
I've recently been introduced to development for iOS by a friend and have begun
Entity Framework has changed drastically since they have introduced version 1. EF 4.1 has
I have tried to keep up with C++ since they introduced 1998 ANSI/ISO C++.
I have been using this for a while, but have since then upgraded to

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.