digitalmars.D - Equality of `pred` Template Parameters
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (18/18) Aug 17 2015 In https://github.com/D-Programming-Language/phobos/pull/3534
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (4/6) Aug 17 2015 If binaryFun!"..." are used as template alias parameters in all
- Timon Gehr (12/17) Aug 17 2015 import std.functional: binaryFun;
- Timon Gehr (4/8) Aug 17 2015 Note that the remaining template arguments to binaryFun are important as...
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (7/11) Aug 17 2015 Not quite what we want, because
In https://github.com/D-Programming-Language/phobos/pull/3534 I'm in need of a generic and correct definition of template isSortedRange(T, alias pred = "a < b") at https://github.com/D-Programming-Language/phobos/pull/3534/files#diff-9f63c74383984a09f5bf578493892e27R1005 To make it general we want it to support `pred` argument of types other than `string`, typically binaryFun!"a < b" Specifically, we want `isSortedRange` to "understand" that binaryFun!"a < b" binaryFun!"a<b" are equvialent and binaryFun!"a < b" binaryFun!"a > b" are not (opposites). I'm guessing there is compile-time-parsing somewhere in Phobos that already does this. Could/Should this be extracted and reused? Destroy!
Aug 17 2015
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`, typicallyIf binaryFun!"..." are used as template alias parameters in all cases is it currently possible to compare these lambdas for equality?
Aug 17 2015
On 08/17/2015 12:13 PM, "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com>" wrote:On Monday, 17 August 2015 at 09:23:56 UTC, Per Nordlöw wrote: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");To make it general we want it to support `pred` argument of types other than `string`, typicallyIf binaryFun!"..." are used as template alias parameters in all cases is it currently possible to compare these lambdas for equality?
Aug 17 2015
On 08/17/2015 02:33 PM, Timon Gehr wrote: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");Note that the remaining template arguments to binaryFun are important as well, they give the parameter names. You might want to use std.traits.TemplateArgsOf.
Aug 17 2015
On Monday, 17 August 2015 at 12:33:28 UTC, Timon Gehr wrote:import std.functional: binaryFun; alias x=binaryFun!"a+b"; alias y=binaryFun!"a+b"; static assert(__traits(isSame,x,y));Not quite what we want, because alias x=binaryFun!"a+b"; alias y=binaryFun!"a + b"; static assert(__traits(isSame,x,y)); fails for me. Can we be dumb for now and just remove space in string?
Aug 17 2015