std.experimental.allocator.make should throw on out-of-memory

Basile Burg via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 20 12:32:01 PDT 2016


On Wednesday, 20 April 2016 at 19:18:58 UTC, Minas Mina wrote:
> On Tuesday, 19 April 2016 at 22:28:27 UTC, Alex Parrill wrote:
>> I'm proposing that std.experimental.allocator.make, as well as 
>> its friends, throw an exception when the allocator cannot 
>> satisfy a request instead of returning null.
>>
>> [...]
>
> I believe it was designed this way so that it can be used in 
> @nogc code, although I might be wrong.

I don't know but in the worst case a system exist to throw @nogc 
exceptions that would work in this case (the message doesn't have 
to be customized so it can be static):

@nogc @safe
void throwStaticEx(T, string file = __FILE__, size_t line = 
__LINE__)()
{
     static const e = new T(file, line);
     throw e;
}

but personaly I 'd prefer that the allocators remains as they are.


More information about the Digitalmars-d mailing list