Instantiating Templates Structs with defaults parameter

bearophile bearophileHUGS at lycos.com
Thu Jun 9 09:52:50 PDT 2011


d coder:

> It would be convenient if I am allowed to use Foo as a type without passing
> parameters (with parameterized functions that is the default behavior). I
> want to understand if not being able to instantiate Foo with default
> parameters is a bug in DMD? Otherwise If it is not allowed in D2, I want to
> know why such a limitation is there.

I think here DMD is working as intended, and I think this design is correc. This behaviour comes from uniformity: the ! (bang) is always required to instantiate a generic/struct/class/enum template. It's not required for function templates if the types can be inferred.

Bye,
bearophile


More information about the Digitalmars-d mailing list