On Friday, 1 February 2013 at 03:08:12 UTC, Zach the Mystic wrote:
On Friday, 1 February 2013 at 01:53:05 UTC, TommiT wrote:
On Friday, 1 February 2013 at 00:59:47 UTC, Zach the Mystic wrote:
writeln(foo.n); // uses alias this to call __mightAsWellBeOpGet

No it won't. It will print "n()".

And that exactly (passing to a templated parameter) is the insurmountable problem in using a variable to represent a property.

to!string(foo.n)... hmmm...

I think this is taken care of actually, with opCast(string). The docs for std.conv.to with opCast may contain a typo:

"toImpl(T, S)(S value);
When source type supports member template function opCast, is is used."

I think it might mean "it is used" since I don't know why it would use "is" instead of the opCast. If that's true, just override opCast(string), no?

Still, it would be great to be able to "prefer" a particular alias this when passed to templates.

Reply via email to