Struct toString works but not std.conv.to!string
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Oct 13 15:43:45 PDT 2015
On Tuesday, 13 October 2015 at 22:21:43 UTC, Ali Çehreli wrote:
> Reduced with a workaround:
>
> struct UTCOffset
> {
> import std.conv : to; // Move to module scope to compile
This introduces UTCOffset.to as an alias to std.conv.to.
> string toString() const
> {
> return "hello";
> }
> }
>
> void main() {
> import std.conv : to;
This ends up being ignored, because UTCOffset has a member called
`to`.
> UTCOffset().to!string;
This does not do call std.conv.to through UFCS. Instead, it calls
UTCOffset's static alias of std.conv.to without an argument.
That is: `UTCOffset().to!string;` = `UTCOffset.to!string;` =
`std.conv.to!string;`
> }
More information about the Digitalmars-d-learn
mailing list