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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:20:27+00:00 2026-05-14T20:20:27+00:00

Is there a reference about C++ Standard Library Exceptions? I just want to know

  • 0

Is there a reference about C++ Standard Library Exceptions? I just want to know that which functions may throw an exception or not.

  • 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-14T20:20:28+00:00Added an answer on May 14, 2026 at 8:20 pm

    Actually, most of the standard library function don’t throw exceptions themselves. They just pass on exception thrown by user code invoked by them. For example, if you push_back() an element to a vector, this can throw (due to memory allocation errors and) if the object’s copy constructor throws.

    A few notable exceptions (no pun intended) where library functions throw are:

    • Some methods will throw out_of_range if the index provided is invalid:
      • std::vector<>::at()
      • std::basic_string<>::at()
      • std::bitset<>::set(), reset() and flip().
    • Some methods will throw std::overflow_error on integer overflow:
      • std::bitset<>::to_ulong() and (C++0x) to_ullong().
    • std::allocator<T> will pass on std::bad_alloc thrown by new which it invokes.
    • Streams can be setup so that std::ios_base::failure are thrown when a state bit is set.
    • Large array allocations can throw std::bad_array_new_length
    • dynamic_cast on a reference can throw a std::bad_cast (technically not part of the standard library)
    • Throwing an invalid exception from a function with an exception specification will throw a std::bad_exception
    • Calling a std::function::operator(...) if it has no value will throw std::bad_function_call.
    • Using typeinfo of a null pointer may throw a std::bad_typeid.
    • Accessing a weak_ptr after the pointee has been released will throw a std::bad_weak_ptr.
    • Incorrect usage of std::promise/std::future may throw a std::future_error.
    • (c++11) The string conversion functions std::stoi, std::stol, std::stoll, std::stoul, std::stoull, std::stof, std::stod, and std::stold can throw both std::invalid_argument and std::out_of_range.
    • (c++11) In the regex family, constructors and assign methods can throw std::regex_error.

    (I’m making this a CW answer, so if anyone can think of more such, please feel free to append them here.)

    Also, for the 3rd edition of The C++ Programming Language, Bjarne Stroustrup has a downloadable appendix about exception safety, which might be relevant.

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

Sidebar

Related Questions

I might be missing something obvious but is there a reference somewhere about what
When there are one of more columns that reference another, I'm struggling for the
I'm reading the book LINQ Pocket Reference and there is a particular example (slightly
What are the steps to estimating using function points? Is there a quick-reference guide
There is very strange assembly reference problem and loading problem I experience with my
Is there any difference between a volatile Object reference and AtomicReference in case I
Is there a way to use (reference) a DLL written in an unmanaged C++
Is there a way to be sure we hold a useable reference to an
Is there a way to have a function return a editable reference to some
Is there a way to reuse a 3rd party control reference? For example, I

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.