Jump to content
  • Advertisement
Sign in to follow this  
TiitHns

stdexcept question

This topic is 3708 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
If you want to know what the what() function returns then I believe this is implementation defined. The exception's constructors in stdexcept take a string and you can store any message in these exceptions.

However, I believe you shouldn't base your response to exceptions on the description string. If I'm not mistaken, you should catch std::bad_alloc& if you are in particular interested in failed memory allocations, and std::exception& if you are just interesting in catching any standard exceptions (including bad_alloc's).

If you want to know what exception types are available consult references, e.g stdexcept reference.

If you want to know which standard function/class throws which exception type, again I believe you should turn to references.

Share this post


Link to post
Share on other sites
Quote:
Original post by visitor
If you want to know what the what() function returns then I believe this is implementation defined. The exception's constructors in stdexcept take a string and you can store any message in these exceptions.


Someone correct me if I'm wrong but I believe the constructor taking a string argument is NOT actually standards compliant but rather a MS VC++ extension.

The standard compliant way to make what() return different strings for different std::exception derived classes is to reimplement what().

Share this post


Link to post
Share on other sites
Quote:
Original post by Red Ant
Someone correct me if I'm wrong but I believe the constructor taking a string argument is NOT actually standards compliant but rather a MS VC++ extension.


In the standard, std::exception does not take a string argument, but all the other exception classes defined in 19.1 (std::runtime_error, std::range_error, etc.) have an explicit const string & argument.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!