[Issue 13971] Writing a container should write its default range

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jan 13 11:45:47 PST 2015


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

Daniel Kozak <kozzi11 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kozzi11 at gmail.com

--- Comment #2 from Daniel Kozak <kozzi11 at gmail.com> ---
It could be done easily by add few lines of code to std.format.formatValue.

Adding something like this:

else static if (__traits(compiles, val[]) && isInputRange!(typeof(val[])))
    {
        auto refVal = val[];
        formatRange(w, refVal, f);
}

to

void formatValue(Writer, T, Char)(Writer w, auto ref T val, ref FormatSpec!Char
f)
if ((is(T == struct) || is(T == union)) && (hasToString!(T, Char) ||
!is(BuiltinTypeOf!T)) && !is(T == enum))

--


More information about the Digitalmars-d-bugs mailing list