On Wednesday, 1 October 2014 at 10:10:51 UTC, Robert burner
Schadek wrote:
lately when working on std.string I run into problems making
stuff nogc as std.utf.decode is not nogc.
https://issues.dlang.org/show_bug.cgi?id=13458
Also I would like a version of decode that takes the string not
as ref.
Something like:
bool decode2(S,C)(S str, out C ret, out size_t strSliceIdx)
if(isSomeString!S && isSomeChar!C) {}
where true is returned if the decode worked and false otherwise.
Ideas, Suggestions ... ? any takers?
Kind of like the "non-throwing std.conv.to": I'm pretty sure that
if you wrote your "tryDecode" function, then you could back-wards
implement the old decode in terms of the new "tryDecode":
dchar decode(ref str)
{
dchar ret;
size_t idx;
enforce(tryDecode(str, ret, idx));
str = str[idx .. $];
return ret;
}
The implementation of tryDecode would be pretty much the old
one's implementation, exceptions replaced in favor of return
false.