How to avoid throwing an exceptions for a built-in function?

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 10 14:43:29 PDT 2017


On Wednesday, 10 May 2017 at 21:19:21 UTC, Stanislav Blinov wrote:
> "nothrow" does not turn off exceptions, it simply forbids 
> throwing them in the enclosing scope (i.e. calling anything 
> that might throw is not allowed).

nothrow disallows the function scope to throw exceptions not 
derived from core.object.Error. It makes no claim about what 
happens *inside* the scope; you can throw as much as you want 
inside nothrow, as long as you take care to catch anything that's 
not a core.object.Error (which is what 
std.exception.assumeWontThrow essentially does).


More information about the Digitalmars-d-learn mailing list