Clay language

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Dec 30 08:11:44 PST 2010


On 12/30/10 10:10 AM, Steven Schveighoffer wrote:
> On Thu, 30 Dec 2010 11:02:43 -0500, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 12/30/10 9:22 AM, Michel Fortin wrote:
>>> I stubbled upon this yesterday:
>>>
>>> Template This Parameters
>>>
>>> TemplateThisParameters are used in member function templates to pick up
>>> the type of the this reference.
>>> import std.stdio;
>>>
>>> struct S
>>> {
>>> const void foo(this T)(int i)
>>> {
>>> writeln(typeid(T));
>>> }
>>> }
>>>
>>> <http://www.digitalmars.com/d/2.0/template.html>
>>>
>>> Looks like you could return the type of this this way...
>>
>> typeof(this) works too.
>
> Nope. the template this parameter assumes the type of 'this' at the call
> site, not at declaration. typeof(this) means the type at declaration time.

Got it. Now I'm just waiting for your next post's ire :o).

Andrei


More information about the Digitalmars-d mailing list