www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Overload Resulution Template with 2 Functions vs. 2 Templates

Why is there a difference between

struct S
{
   template func(T)
   {
     enum impl = "whatever string";
     auto func(T arg)       { mixin(impl); } // eponymous template
     auto func(T arg) const { mixin(impl); } // eponymous template
   }
}

and

struct R
{
   private enum impl = "whatever string";
   auto func(T)(T arg)       { mixin(impl); }
   auto func(T)(T arg) const { mixin(impl); }
}

And what is the difference exactly? I know that
   auto func(T)(T arg) { mixin(impl); }
is strictly equivalent to
   template func(T) { auto func(T)(T arg) { mixin(impl); } }
so the difference is just 2 templates 1 function each vs. 1 
template 2 functions.

I don't have a simple example; here is no difference observable. 
The issue is with std.typecons.Tuple.opCmp; there are two 
templates and I tried making it one, as the implementation is 
identical. Unfortunately, one cannot use `inout` for more or less 
obcious reasons.
An attempt to put them into one template (as for struct S) does 
not work either, but I don't understand why. Solution like struct 
R works.

Is there a complete reference for how overload resolution works 
in D, including implicit template instantiation?
May 06 2018