[Issue 4466] std.conv: parse!(T, S)(S, uint radix) the opposite of to to!(T, S)(S, uint radix)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 15 07:50:10 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4466


Lionello Lunesu <lio+bugzilla at lunesu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|nobody at puremagic.com        |andrei at metalanguage.com


--- Comment #2 from Lionello Lunesu <lio+bugzilla at lunesu.com> 2010-07-15 07:50:08 PDT ---
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.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list