Bug 4466 – std.conv: parse!(T,S)(S, uint radix) the opposite of to to!(T,S)(S, uint radix)

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-07-15T07:45:00Z
Last change time
2011-07-01T05:55:23Z
Assigned to
andrei
Creator
lio+bugzilla

Attachments

IDFilenameSummaryContent-TypeSize
691std_conv_parse_radix.patchpatch to std.conv, adds parse!(T,S)(S, uint radix)text/plain2145

Comments

Comment #0 by lio+bugzilla — 2010-07-15T07:45:59Z
Comment #1 by lio+bugzilla — 2010-07-15T07:46:57Z
Created attachment 691 patch to std.conv, adds parse!(T,S)(S, uint radix)
Comment #2 by lio+bugzilla — 2010-07-15T07:50:08Z
I've added the following function to std.conv: Target parse(Target, Source)(ref Source s, uint radix) Check the unittest: unittest { foreach (i; 2..36) { assert(parse!int("0",i) == 0); assert(parse!int("1",i) == 1); assert(parse!byte("10",i) == i); } assert(parse!int("0011001101101",2) == 0b0011001101101); assert(parse!int("765",8) == 0765); assert(parse!int("fCDe",16) == 0xfcde); } The unittest passes, were it not for bug 4309. (The "ref" in "ref Source" apparently changes the pointer to the string literal.)
Comment #3 by yebblies — 2011-07-01T05:55:23Z
Closing as the function is now in phobos and works.