readln with buffer fails

dcrepid via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 29 14:14:13 PDT 2014


I have this simple code:
int main()
{
     import std.stdio;
     char[4096] Input;
     readln(Input);
     //readln!(char)(Input);  // also fails
     return 0;
}

I get these messages during compilation:
test.d(39): Error: template std.stdio.readln cannot deduce 
function from
argument types !()(char[4096]), candidates are:
  src\phobos\std\stdio.d(2818):
     std.stdio.readln(S = string)(dchar terminator = '\x0a') if 
(isSomeString!S)
  src\phobos\std\stdio.d(2851):
     std.stdio.readln(C)(ref C[] buf, dchar terminator = '\x0a') 
if (isSomeChar!C && is(Unqual!C == C) && !is(C == enum))
  src\phobos\std\stdio.d(2858):
       std.stdio.readln(C, R)(ref C[] buf, R terminator) if 
(isSomeChar!C && is(Unqual!C == C) && !is(C == enum) && 
isBidirectionalRange!R && is(typeof(terminator.front == 
(dchar).init)))

Now, I'm used to 'buffer' meaning one thing, but here it seems 
that buffer means something more akin to a 'sink' object, or a 
forced dynamic array type?  Is there some way I can avoid dynamic 
allocations?

Thanks!


More information about the Digitalmars-d-learn mailing list