Getting the overload set of a template

Simen Kjærås simen.kjaras at gmail.com
Sat Apr 21 19:51:05 UTC 2018


On Saturday, 21 April 2018 at 11:23:33 UTC, Alex wrote:
> On Thursday, 19 April 2018 at 17:55:47 UTC, Simen Kjærås wrote:
>> Your first example defines two templates (which are overloads 
>> of the same name), the second only one. There's no ambiguity 
>> there.
>
> So, do you mean, that the constraint belongs to the interface 
> of a template?

Not necessarily - it depends on what you want to achieve. The 
only thing I mean is that the code clearly defines two templates 
in one case (and chooses which template to instantiate based on 
the arguments), and one template in the other (and chooses the 
contents of that template based on the arguments). Sure, the end 
result may be similar*, but how it works in the language is 
clearly defined, and different between the two cases.

*In this case, there are important differences - in the first 
case the template itself is marked with a UDA, in the second the 
enum member is. In the first case foo!"c" will fail to 
instantiate, in the second it won't.

--
   Simen


More information about the Digitalmars-d-learn mailing list