Andrej Mitrovic <[email protected]> wrote:

On 12/31/10, Simen kjaeraas <[email protected]> wrote:


This will give you both:

class A
{
    void bar(this T) ( )
    {
        writeln(typeid(T));
        writeln(typeid(this));
    }
}

class B : A
{
}

void main( )
{
    A a = new B;
    a.bar();
}

Indeed it will. Now, if you look closely, you will see that typeid(T) is A, while typeid(this) is B. Testing further:

class A {
   void baz() {
       writeln(typeid(this));
   }
}
class B : A {
}

void main() {
    A a = new B;
    a.baz(); // prints B.
}

We thus see that the template this parameter has absolutely no value.


--
Simen

Reply via email to