nothrow and std.exception.ifThrown
novice2
sorryno at em.ail
Thu Apr 29 16:02:20 UTC 2021
Hello.
I need use std.format.format() in nothrow function.
format() can throw.
For this case i have special default string.
I don't want embrace format into try..catch block,
and i found elegant std.exception.ifThrown.
But DMD say "ifThrown not nothrow"
https://run.dlang.io/is/kXtt5q
```d
nothrow string foo(int x, string def) {
import std.format: format;
import std.exception: ifThrown;
return format("%d", x).ifThrown(def);
}
Error: function std.exception.ifThrown!(Exception, string,
string).ifThrown is not nothrow
```
What i can use instead of ifThrown, or how it can be changed to
nothrow?
Thanks.
More information about the Digitalmars-d-learn
mailing list