Default Template Instantiation
Jonathan Marler via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 19 12:38:37 PDT 2016
If you have a template where:
1) All parameters are optional
2) The parameters cannot be deduced
Would it be reasonable to instantiate the template with the
default parameter values? For example:
template Foo(string str = "some string", T...)
{
class Foo
{
// class implementation
this() { }
}
}
auto foo = new Foo!()(); // OK
auto foo = new Foo(); // Error: cannot deduce template parameters
In this example, there's no way to deduce the template parameters
for Foo, however, since they are not specified, would it be
reasonable to just use the defaults? str would be "some string"
and T would be empty?
More information about the Digitalmars-d
mailing list