runtime hook for Crash on Error
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jun 6 06:26:09 PDT 2012
On Wed, 06 Jun 2012 05:13:39 -0400, Lars T. Kyllingstad
<public at kyllingen.net> wrote:
> 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.olsh at 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.
That doesn't work, new conflates memory allocation with construction.
What if the constructor throws?
-Steve
More information about the Digitalmars-d
mailing list