www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18168] New: std.base64.encode for output ranges should be

https://issues.dlang.org/show_bug.cgi?id=18168

          Issue ID: 18168
           Summary: std.base64.encode for output ranges should be usable
                    in  safe
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

void test()  safe
{
    import std.base64;
    struct OutputRange
    {
        char[] result;
        void put(const(char) ch)  safe
        {
            result ~= ch;
        }
    }

    ubyte[] data = [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e];
    OutputRange output;
    assert(Base64.encode(data, output) == 8);
    assert(output.result == "Gis8TV1u");
}

--
Jan 02 2018