I can has @nogc and throw Exceptions?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 13 13:13:08 PST 2015


On 2/13/15 4:08 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" 
wrote:
> On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath wrote:
>> 1. Throw preallocated exceptions is the way to go
>
> .... and because noone has yet shown an explicit example:
>
>      void myThrowingNogcFunc() @nogc {
>          static const exc = new Exception("something went wrong");
>          throw exc;
>      }
>
> As long as you don't need to pass a runtime argument to the constructor,
> there's no need for emplace acrobatics.

shared static const, unless you want one per thread (doesn't make a 
whole lot of sense, since it's const).

-Steve


More information about the Digitalmars-d-learn mailing list