?
Solved

How can you tell when a multimap insertion fails due to Out Of Memory

Posted on 2012-04-04
1
Medium Priority
?
266 Views
Last Modified: 2012-04-07
Quite simply, how can you tell when a multimap insertion fails due to running out of memory?  I expected that this would be easily found on Google but have had no luck.  My two guesses would be that it would return end() or that it would throw an exception but I haven't managed to find anything definitive.
0
Comment
Question by:iyac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
ambience earned 150 total points
ID: 37806513
Nope it will definitely not return end() because of an out of memory condition. I'm saying this because thats not a general design strategy in STL. The world is divided wrt whether new operator would throw std::bad_alloc when it fails to allocate memory or not. STL variant that favor exceptions - possibly this behavior is configurable - you can expect a std::bad_alloc exception. For others, I'm not sure - but i think it will just crash.

For example, VisualStudio has the define

#define _HAS_EXCEPTIONS 1

If you set this to 0 it will not throw std::bad_alloc.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question