On Monday, 19 September 2016 at 19:38:37 UTC, Jonathan Marler
wrote:
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?
My understanding of this case is that the usage of the eponymous
member must include all the template parameters because for
example we could have:
template Foo(string str = "some string", T...)
{
class Foo
{
T[0] a;
T[1] b;
// class implementation
this() { }
}
}
The way "new Foo" is used must tells what are the parent template
parameters.