How to turn an inout(Object) into a string
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 25 20:47:59 PDT 2015
On Sunday, 26 April 2015 at 03:09:17 UTC, Meta wrote:
> The following code spits out pages of error messages, and it's
> driving me insane. I know that Object.toString only has a
> mutable variant, so how am I supposed to use writeln, toString,
> etc. with an inout, const, or immutable object?
>
> void main(inout string[] args)
> {
> import std.stdio;
>
> immutable(Object) o = new immutable Object();
> //Compile error: template instance
> //std.format.formatGeneric!(
> // LockingTextWriter, immutable(Object),
> // char)
> //error instantiating
> writeln(o);
> }
writeln( cast(Object)o );
Tada!!
More information about the Digitalmars-d-learn
mailing list