How can I print inout parameters?
import std.stdio;
void main()
{
foo(2);
return;
}
inout(int) foo(inout(int) x)
{
writeln(x);
return x;
}
Compiler output:
c:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3881): Error: template instance Unqual!(__T4ImplTNgiZ) does not match template declaration Unqual(T)
c:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(757): Error: template instance std.conv.toTextRange!(inout(int), LockingTextWriter) error instantiating
c:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1708): instantiated from here: write!(inout(int), char)
x.d(11): instantiated from here: writeln!(inout(int))
c:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1708): Error: template instance std.stdio.File.write!(inout(int), char) error instantiating
x.d(11): instantiated from here: writeln!(inout(int))
x.d(11): Error: template instance std.stdio.writeln!(inout(int)) error instantiating
Also, to!string doesn't work with the inout parameter.
Update: I've just found out (by trial and error) that the following works:
writeln(cast(const)x);
Is this the normal method or am I missing something?
This is a library bug, most likely in Unqual. I added it here: http://d.puremagic.com/issues/show_bug.cgi?id=10544
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With