tryTo: non-throwing variant of std.conv.to
Per Nordlöw
per.nordlow at gmail.com
Wed Aug 15 12:03:56 UTC 2018
On Wednesday, 15 August 2018 at 09:26:26 UTC, Seb wrote:
>> If so, AFAICT, existing std.conv.to should be implemented on
>> top of std.conv.tryTo.
>
> Well, for now you can use `ifThrown` from std.exception:
>
> https://dlang.org/phobos/std_exception.html#ifThrown
>
> ---
> "foo".to!int.ifThrown(42)
But the whole idea is to avoid both throwing and catching
exceptions at all. As this results in orders of magnitudes of
drop in performance for the throwing case. That's the reason why
Folly has this aswell.
Thanks anyway, Seb.
More information about the Digitalmars-d-learn
mailing list