Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a list of c++11 standard library interfaces which require exceptions enabled?

From reading revision N3242 of the c++11 draft, it appears that some components of the standard library's interfaces (notably threading and locking) depend on exception handling.

Since I do a lot of work with exceptions disabled, I am wondering which library components/features will be (practically or logically) unusable without exception handling enabled?

like image 944
justin Avatar asked Sep 12 '11 08:09

justin


2 Answers

First of all (just as a reminder), disabling exceptions and RTTI are compiler specific extensions the Standard has no consideration for.

Since the Standard Library is usually tied to the compiler, it may be that your implementation of the Standard Library has been specifically designed to cope with this (and in particular, to cope with new returning null pointers instead of raising std::bad_alloc).

Therefore, what you ask for is non-sensical. Check the documentation of your own library for a complete list.

That being said, the Standard does guarantee that a number of operations will never throw. I don't know of any operation that swallows exceptions, I would suppose that most of them are actually safe to use as-is.

For example, all algorithms should be safe.

Still, once again, I can only recommend reading the documentation of your implementation.

like image 123
Matthieu M. Avatar answered Nov 08 '22 01:11

Matthieu M.


This question is over one month old, and unanswered.

I am providing an answer which can be considered a community wiki, add to it as needed.

  • std::thread Section 30.2.2. Transitive. Abstraction implemented using native implementations.

  • std::mutex, std::recursive_mutex, std::timed_mutex, std::recursive_timed_mutex. Section 30.4.1, Intransitive if you supply your own exception free locking (via BasicLockable, Lockable, TimedLockable). Abstraction implemented using native implementations.

  • std::condition_variable Section 30.5. Transitive. Abstraction implemented using native implementations.

note: There will be more.

like image 1
justin Avatar answered Nov 07 '22 23:11

justin