Ivan Kazmenko:

(1) Should I refrain from using this as a type, is it a bug?

Using typeof(this) is OK, and makes code more DRY.


(2) A matter of style: what is the idiomatic way to take the exact type of a templated struct? For example, which method signature to return a typeof(this) value is "better" in which way if all have the same effect:
-----
struct S (A, B, C)
{
...
        auto method () {...}
        S method () {...}
        S !(theA, theB, theC) method () {...}
        typeof (this) method () {...}
}

I think there is no common idiom here. Generally being DRY is good. typeof(this) is more explicit than auto, so I prefer that.

Bye,
bearophile

Reply via email to