normal function and template function conflict
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jul 26 12:56:31 PDT 2012
On Thursday, July 26, 2012 21:49:35 Andrej Mitrovic wrote:
> On 7/26/12, Jacob Carlborg <doob at me.com> wrote:
> > void seed () (UIntType value = default_seed)
> >
> > Less typing as well.
>
> Yep. It's funny how this works at all. I mean a template with no
> template parameters is somehow still a template. :)
It _is _ bit funny, but Ibelieve that it comes from permitting empty template
parameter lists. Without that, recursion with eponymous templates would become
problematic. e.g.
enum template myTemplate(T...)
{
static if(T.length == 0)
enum myTemplate = 42;
else
enum myTemplate = T[0] * 3 + myTemplate!(T[1 .. $]);
}
needs to be able to take an empty parameter list. It's probably possible to
make that work without allowing an outright empty parameter list that isn't
even a variadic template, but I suspect that it's just easier to allow it.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list