Why a template with Nullable does not compile?

Victor Porton porton at narod.ru
Tue Mar 12 15:26:05 UTC 2019


template FieldInfo(T, Nullable!T default_) {
}

On Tuesday, 12 March 2019 at 09:05:36 UTC, Nicholas Wilson wrote:
> It seems to be getting confused between the two types of 
> Nullable, namely:
> Nullable(T), and
> Nullable(T, T defaultVal)

I don't understand why exactly it is getting confused. How can it 
decide that "Nullable!T default_" is a two-arguments template 
when it is so not "Nullable!(T, default_)"? Please explain the 
EXACT cause of the error.

> template FieldInfo(T) {
>     template FieldInfo(Nullable!(T) default_)
>     {
>         enum FieldInfo = 0;
>     }
> }
>
> seems to work, but I can't seem to instantiate one of it.

Why you use the same name "FieldInfo" for both the template and 
its subtemplate? Does it make some sense?


More information about the Digitalmars-d-learn mailing list