What is a reference about the C ++ standard library exception? I just want to know which works can throw exceptions or not.
In fact, most standard library functions do not throw exceptions themselves. They simply pass on the exceptions threw by the user code applied by them. For example, if you can remove push_back () from an element of a vector, it can throw (due to memory allocation errors) and if the copy produces the creator throws
A few notable exceptions (no intention) where library throws functions:
- Throw out some methods
out_of_rangeif the provided index is invalid:-
std :: vector & lt; & Gt; :: at () -
std :: basic_string & lt; & Gt; :: at () -
std :: bitset & lt; & Gt; :: Set (),reset ()andflip (). - Some methods will throw
std :: overflow_errorover the integer overflow:-
std :: bitset < & Gt; ; :: to_ulong ()and (C + 0x)to_ullong ().
-
-
std :: allocator & lt; T & gt;std :: bad_allocwill be thrown bynewwhich invites it - You can set up the stream so that a state bit set
std :: ios_base :: failureis thrown on - large array allocation
std :: bad_array_new_length - if any Dynamic_cast on reference
std :: bad_cast(technically not part of standard library) - With an exception specification, throwing an invalid exception from a function
std :: bad_exception -
Std :: function :: operator (...)if it does not have any value thenStd :: bad_function_call. -
TypeInfocan throwstd :: bad_typeidof a zero pointer. - After the release of Pointei by reaching
weak_ptrStd :: bad_weak_ptr. -
std :: future_errorcould throw away from the wrong use ofstd :: promise / std :: future. - (c + + 11) string conversion function
std :: stoi,std :: stol,Std :: stoll,std :: stoul,std :: stoull,std :: stof,std: : Stod, andstd :: stoldbothstd :: invalid_argumentandstd :: out_of_range. - (c ++11) In the Regedx family, the constructor and assignment methods can remove
std :: regex_error.
(I am making it a CW answer, so if someone can think of such a thing, please do not hesitate to attach them here.)
In addition, for the 3rd edition C ++ programming language , downloadable in Burgeley Strawstrop, which can be relevant
-
Comments
Post a Comment