On Thursday, 29 October 2015 at 08:27:04 UTC, Daniel N wrote:
On Thursday, 29 October 2015 at 01:52:16 UTC, bitwise wrote:
[...]
There's a famous idiom from the C++ world which solves this,
google CRTP...
... or see the quick hack below.
('final' is optional, the interface is also optional...)
interface IBase
{
string Name();
}
class Base(T) : IBase
{
final string Name()
{
return typeof(this).stringof;
}
}
class One : Base!One { }
class Two : Base!Two { }
Doesn't work with multiple levels of inheritance...
Bit