On Tuesday, 2 July 2013 at 19:39:56 UTC, Maxim Fomin wrote:
[..] This is how alias this is designed to work. What have you surprised here?

I had started to think about "alias this" as C++'s implicit conversion operator. And I remembered wrong how "alias this" was explained in TDPL. I remembered it somehow like this:

"Whenever a variable der of type Derived is used where a type Base is expected, the compiler tries der.getBase also." (assuming "alias getBase this;" in Derived)

And since a templated parameter doesn't *expect* anything, I figured it wouldn't convert.

But "alias this" is defined in TDPL (page 265) like so:
"The workings of alias payload this are quite simple. Whenever a value obj of type Final!T is used in a context that would be illegal for its type, the compiler rewrites obj as obj.payload."

Just an honest mistake on my part.

Reply via email to