digitalmars.D.learn - Can't print inout parameter
- Jacob Carlborg (28/29) Oct 04 2012 The example below fails to compile:
- gerleim (5/10) Jul 03 2013 I don't know if this is the official method, but
The example below fails to compile: inout(int) foo (inout int a) { writeln(a); return a; } void main () { foo(1); } If I remove the call to "writeln" it compiles. DMD 2.060 on Mac OS X, error message: conv.d(3572): Error: template instance Unqual!(__T4ImplTNgiZ) Unqual!(__T4ImplTNgiZ) does not match template declaration Unqual(T) conv.d(3572): Error: Unqual!(__T4ImplTNgiZ) is used as a type stdio.d(692): Error: template instance std.conv.toTextRange!(inout(int),LockingTextWriter) error instantiating stdio.d(1595): instantiated from here: write!(inout(int),char) main.d(10): instantiated from here: writeln!(inout(int)) stdio.d(1595): Error: template instance std.stdio.File.write!(inout(int),char) error instantiating main.d(10): instantiated from here: writeln!(inout(int)) main.d(10): Error: template instance std.stdio.writeln!(inout(int)) error instantiating Failed: /Users/jacob/.dvm/bin/dvm-current-dc -v -o- '/Users/jacob/development/d/main.d' -I'/Users/jacob/development/d'/Users/jacob/development/d/main.d.deps-- /Jacob Carlborg
Oct 04 2012
inout(int) foo (inout int a) { writeln(a); return a; }I don't know if this is the official method, but writeln(cast(const)x); works. Trying to get answers at: http://stackoverflow.com/questions/17460065/how-to-print-inout-parameters
Jul 03 2013