Le 06/06/2012 11:13, Lars T. Kyllingstad a écrit :
On Friday, 1 June 2012 at 12:29:27 UTC, Steven Schveighoffer wrote:
On Fri, 01 Jun 2012 04:48:27 -0400, Dmitry Olshansky
<dmitry.o...@gmail.com> wrote:
I don't agree that OutOfMemory is critical:
--> make it an exception ?
No. What we need is a non-throwing version of malloc that returns
NULL. (throwing version can wrap this). If you want to throw an
exception, then throw it there (or use enforce).
With some sugar:
auto a = nothrow new Foo; // Returns null on OOM
Then, ordinary new can be disallowed in nothrow code.
IMO, failing assertions and out-of-bounds errors should just abort(),
or, as Sean suggests, call a special handler.
-Lars
Let see what Andrei propose for custom allocators.