Thread overview
[Issue 4466] New: std.conv: parse!(T,S)(S, uint radix) the opposite of to to!(T,S)(S, uint radix)
Jul 15, 2010
Lionello Lunesu
Jul 15, 2010
Lionello Lunesu
Jul 15, 2010
Lionello Lunesu
Jul 01, 2011
yebblies
July 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4466

           Summary: std.conv: parse!(T,S)(S, uint radix)  the opposite of
                    to to!(T,S)(S, uint radix)
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: lio+bugzilla@lunesu.com


--- Comment #0 from Lionello Lunesu <lio+bugzilla@lunesu.com> 2010-07-15 07:45:59 PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4466



--- Comment #1 from Lionello Lunesu <lio+bugzilla@lunesu.com> 2010-07-15 07:46:57 PDT ---
Created an attachment (id=691)
patch to std.conv, adds parse!(T,S)(S, uint radix)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4466


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

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


--- Comment #2 from Lionello Lunesu <lio+bugzilla@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: -------
July 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4466


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED


--- Comment #3 from yebblies <yebblies@gmail.com> 2011-07-01 22:55:23 EST ---
Closing as the function is now in phobos and works.

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