Unable to instantiate template with same name as function

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 3 06:09:25 PST 2016


On Thursday, 3 March 2016 at 08:58:25 UTC, Shriramana Sharma 
wrote:
> Hello people and thanks for your replies.
>
> Jonathan M Davis via Digitalmars-d-learn wrote:
>
>> You can't overload a function and an eponymous template like 
>> that. They need to have distinct names.
>
> Why is it not possible for the overload to happen? After all, 
> the compiler should be able to identify which to use by seeing 
> whether it is followed by ! or (), no?

Note that parentheses are optional when no argument is provided. 
Most functions that you use from phobos are really template 
functions for example  but most of the time you don't use them 
with a template argument. So no, the compiler can't make the 
distinction.


More information about the Digitalmars-d-learn mailing list