[Article Submission] Have Your Efficiency, and Flexibility Too
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jun 1 07:37:41 PDT 2011
On Wed, 01 Jun 2011 10:32:10 -0400, Timon Gehr <timon.gehr at gmx.ch> wrote:
> Steven Schveighoffer wrote:
>> I think there are certain special situations where you can use
>> typeof(this). For example, as the return type for a static method.
>>
>> *looks for doc* Couldn't find any documentation on it...
>>
>> It's somewhat like static this, which is inflexible in how you write it.
>>
>> -Steve
>
> It is not documented in detail but it is there =).
> See: http://www.digitalmars.com/d/2.0/declaration.html
> "1. typeof(this) will generate the type of what this would be in a
> non-static
> member function, even if not in a member function. "
D'oh! I must have skipped over that page.
>
> Therefore it is not special cased, but is supposed to work universally.
>
> That it does not work for Nick is probably a bug, not a sensible and
> thought-out
> limitation. It can be very handy for Metaprogramming, this needs to get
> fixed at
> some point.
>
> @Nick: Can you try to deduce a minimal test case? (Or provide the full
> listing of
> the code?)
I agree with all of this, I think it should work, judging from that
documentation.
-Steve
More information about the Digitalmars-d
mailing list