Can't seem to call super constructor if it's a template

Steven Schveighoffer schveiguy at
Wed Aug 12 11:10:42 UTC 2020

On 8/12/20 2:22 AM, Alexandru Ermicioi wrote:
> On Monday, 10 August 2020 at 18:37:06 UTC, Andrei Alexandrescu wrote:
>> class A {
>>     this(T)() {}
>> }
>> class B : A {
>>     this() { super!int(); }
>> }
>> Error: found ! when expecting ; following statement
>> That should work, shouldn't it?
> It is not possible to call cobstructors with explicit template 
> parameters. There was documentation note about that from what I 
> remember, though for some reason I can't find yet.
> Reason for that may be the case where you have templated class with 
> templated constructor. How would user pass template args to class itself 
> and then to constructor?

A derived class doesn't have to pass template parameters to the base 
type. super!T should be unambiguous.

It's true that a templated constructor with explicit parameters couldn't 
be created with that constructor without adding some syntax mechanism 
for it. But it could be derived from.


More information about the Digitalmars-d mailing list