Template functions, can we make it more simple?

Timon Gehr timon.gehr at gmx.ch
Fri Aug 2 15:17:22 PDT 2013


On 08/03/2013 12:06 AM, Andrej Mitrovic wrote:
> On 8/2/13, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>> auto fun(auto x, auto y) { … }
>>
>> Truth be told, at the time of that decision
>> parameter names (viz. x and y) could not be used in template
>> constraints. Now they could, so in a way that reopens the question.
>
> You'd still have to use typeof(x) and typeof(y) to extract the types,
> so even though you end up making the template declaration simpler you
> also make the constraint more complicated.
> ...

bool compare(a,b) if(__traits(compiles,a<b)) { return a<b; }



More information about the Digitalmars-d mailing list