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 7509785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:01:27+00:00 2026-05-29T23:01:27+00:00

Consider a standard iterator where it is necessary to allocate memory for traversing a

  • 0

Consider a standard iterator where it is necessary to allocate memory for traversing a data structure. Does the standard allow an iterator to throw an exception if memory cannot be allocated? As an example, think of an input iterator for tree data structures. In this case, to traverse the tree you have to either add and maintain a pointer to the parent of each node (which would slow down operations not needing such a pointer, as for insert/erase/find on the tree) or use a stack to help the iterator store the pointers to the traversed nodes. In this case, while advancing the stack could grow until there is no more free memory and the iterator is compelled to throw.

  • 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-29T23:01:29+00:00Added an answer on May 29, 2026 at 11:01 pm

    Yes an iterator method in C++ is allowed to throw and as you pointed out can throw in certain circumstances.

    The only class of functions in C++ that can’t throw is a destructor. And really that’s just by convention (because it makes certain operations nearly impossible to do correctly). Destructors can throw, it’s just very bad to let them do so.

    Individual functions can be marked with throw() to prevent them from throwing.

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

Sidebar

Related Questions

Consider a standard ASP.NET web application where the user types in some numeric data
Consider the following 3 standard statements $queryString = SOME SQL SELECT QUERY; $queryResult =
I'd consider myself a reasonable standard CSS/XHTML chap but I'm pretty baffled by this.
Consider the 0/1 knapsack problem . The standard Dynamic Programming algorithm applies only when
I support SQL Servers 2000 thru 2008R2 (all Standard Edition). Question 1 Please consider
I have what I'd consider a standard .NET MVC3 Repository pattern project that I've
Consider a data entry form where the user needs to enter times in military
Consider following piece of code void foo( bool forwad ) { vector<MyObject>::iterator it, end_it;
Consider an standard normalized many-to-many tag system (three tables of articles, tags, tag_map). I
Consider: command1 | command2 Is the output of command1 used as standard input of

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.