Builtin Support for Comparison Function for Primitive Types

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 2 01:33:25 PDT 2015


On Saturday, 2 May 2015 at 08:29:11 UTC, Per Nordlöw wrote:
> Why doesn't std.algorithm.comparison.cmp support primitive 
> types such as
>
>     assert(cmp(0,1) == true);
>
> ?

I just found some forgotten code of my that solves it through

     import std.range: only;
     assert(cmp(only(0), only(1)) == -1);

Why the detour over std.range.only()?


More information about the Digitalmars-d-learn mailing list