Equality of `pred` Template Parameters

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 17 05:33:27 PDT 2015


On 08/17/2015 12:13 PM, "Per =?UTF-8?B?Tm9yZGzDtnci?= 
<per.nordlow at gmail.com>" wrote:
> On Monday, 17 August 2015 at 09:23:56 UTC, Per Nordlöw wrote:
>> To make it general we want it to support `pred` argument of types
>> other than `string`, typically
>
> If binaryFun!"..." are used as template alias parameters in all cases is
> it currently possible to compare these lambdas for equality?

import std.functional: binaryFun;

alias x=binaryFun!"a+b";
alias y=binaryFun!"a+b";
alias z=binaryFun!"a-b";
static assert(__traits(isSame,x,y));
static assert(!__traits(isSame,y,z));

enum binaryFunString(alias x:binaryFun!T,T...)=T[0];

static assert(binaryFunString!x=="a+b");
static assert(binaryFunString!y=="a+b");
static assert(binaryFunString!z=="a-b");



More information about the Digitalmars-d mailing list