Andrei Alexandrescu wrote:
James Hopkin wrote:
On Sep 23, 1:29 am, Andrei Alexandrescu
<SeeWebsiteForEm...@erdani.org> wrote:
Mathias Gaunard wrote:
All default constructors of containers are not required to be
nothrow. Electronic Arts has asked the standard to change that,
however, showing their own EASTL as an improvement upon the STL.
I'm of the same opinion as them.
Andrei
Me too, but I don't think it implies much about whether throwing
default constructors *in general* are problematic.
I agree. So let me restart. Do you agree that in a GC system, there
should be _some_ constructor that doesn't throw (that being the
constructor called when the object enters the destroyed state)? If we
do agree on that, what remains is to define that constructor.
No, I don't agree that *every* class must have a no-throw constructor.
If a class has a natural state that can be reached without performing
operations that can potentially throw, then that particular class
should have a no-throw constructor.
But I am not willing to introduce an artificial zombie-state just to
keep the people happy that don't like throwing constructors.
In my opinion, a wrapper around an OS mutex should not have a state
where it does not own a mutex. If getting a mutex from the OS can
throw, then this wrapper class will not have any no-throw constructors.
(And using it after the destructor has returned the mutex to the OS is a
bug.)
question.
[ comp.lang.c++.moderated. First time posters: Do this! ]