Is this actually supposed to be legal?
Brad Roberts
braddr at puremagic.com
Mon Jul 16 22:37:18 PDT 2012
http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
On 7/16/2012 10:24 PM, Jonathan M Davis wrote:
> This code strikes me as being a bug:
>
> --------
> class MyBase(T)
> {}
>
> class MySubA : MyBase!MySubA
> {}
>
> class MySubB : MyBase!MySubB
> {}
>
> void main()
> {}
> --------
>
> but it compiles just fine. However, given the fact that MySubA isn't even
> properly defined until its base class has been defined, I don't see how it could
> possibly _not_ be a bug for the base class to be templatized on it. You could
> get some really weird behavior if you use compile time reflection on the
> derived class in the base class definition.
>
> Does anyone know if this is actually supposed to work? Or is it in fact a bug
> like I think it is?
>
> - Jonathan M Davis
>
More information about the Digitalmars-d-learn
mailing list