digitalmars.D.learn - Passing Appender by value
- Andrej Mitrovic (19/19) Jun 22 2013 I just learned today that passing Appender by value does not have the
I just learned today that passing Appender by value does not have the
semantics I thought it would:
-----
import std.array;
import std.stdio;
void call(Appender!(int[]) buffer)
{
buffer.put(1);
}
void main()
{
Appender!(int[]) buffer;
writeln(buffer.data); // writes [], it's empty
}
-----
Is this a bug? If not, shouldn't we introduce a disabled copy
constructor to force passing Appender by ref to functions to avoid
this type of user bug?
I can't see how the current behavior is useful to anyone.
Jun 22 2013








Andrej Mitrovic <andrej.mitrovich gmail.com>