Appender example doesn't work with GDC. GDC bug?

BoraxMan rotflol2 at hotmail.com
Sat Dec 28 03:08:48 UTC 2019


The example for appender located here, does not compile with GDC.

https://dlang.org/library/std/array/appender.html

void main()
{
     import std.array;
     import std.stdio: write, writeln, writef, writefln;
     auto w = appender!string;
     // pre-allocate space for at least 10 elements (this avoids 
costly reallocations)
     w.reserve(10);
     assert(w.capacity >= 10);

     w.put('a'); // single elements
     w.put("bc"); // multiple elements

     // use the append syntax
     w ~= 'd';
     w ~= "ef";

     writeln(w[]); // "abcdef"


}

For the line "Writeln(w[]);" GDC reports "error: no [] operator 
overload for type Appender!string".

It works with DMD.

Time to file  a bug report with GCC-GDC?



More information about the D.gnu mailing list