On Saturday, 22 April 2017 at 12:16:19 UTC, Nordlöw wrote:
On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: If I get this to work, I'm gonna try pushing it into std.conv.
Another bit to pick on is the return value. auto x = toWithDefault!int("1", 0.0f);typeof(x) will be float even though the caller requested a conversion to int.
Probably should be T toWithDefault(T,S,U)(S v, /*lazy*/ U defaultValue) if (is(typeof(() { T r = defaultValue; }))) { //... }