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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:32:02+00:00 2026-05-26T04:32:02+00:00

I want to use map in C++ , but I don’t use exceptions. After

  • 0

I want to use map in C++, but I don’t use exceptions. After using map<int, int> my_map in a function, how can I check if it managed to allocate memory internally (I understand that with exceptions any new inside that can’t allocate memory will throw an exception)?

  • 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-26T04:32:02+00:00Added an answer on May 26, 2026 at 4:32 am

    Whether or not you use exceptions, the standard containers will (if they are using their default allocators) throw std::bad_alloc if a memory allocation fails. If you don’t catch this, then your program will terminate – so there is no way to check for success without catching the exception in this case.

    If you really want to eradicate exceptions (which in my opinion is a bad idea, even if you don’t want to use the Standard Library), then you will have ditch the standard containers, rewriting whatever containers you want to use a non-standard allocation model, and check for and propagate any failures. The standard containers all assume that allocation will either succeed or throw, so they cannot be used with an allocator that doesn’t give that guarantee.

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

Sidebar

Related Questions

I want to have a map of vectors, (but I don't want to use
I am new to the structure map but i want to use it in
I want to use coroutines in C (Linux), but I don't want to waste
I want to use MapView control in satellite view mode but i don't want
I want to merge Two HashMaps. I could use map1.putAll(map2); but I don't want
I am a new android app developer and i want to use google map
I have a header file. In this header I want to use a map
I want to use a C++ map structure, such as map<vector<DFSCode>, vector<PDB>> candidate ,
I want to place markers on the map. I want to use the standard
For instance, if I want to map property Title I use: > Map(x =>

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.