www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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



07:45:59 PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 15 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4466




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: -------
Jul 15 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 15 2010
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 01 2011