May 05, 2016
Is there a way to calculate unique enum members without using sort, such as *not* done in my current implementation:

auto uniqueEnumMembers(T)()
{
    import std.traits: EnumMembers;
    import std.algorithm: sort, uniq;
    return [EnumMembers!T].sort().uniq;
}

Preferrably both at compile-time and run-time.
May 05, 2016
On Thursday, 5 May 2016 at 12:54:08 UTC, Nordlöw wrote:
> Is there a way to calculate unique enum members without using sort, such as *not* done in my current implementation:
>
> auto uniqueEnumMembers(T)()
> {
>     import std.traits: EnumMembers;
>     import std.algorithm: sort, uniq;
>     return [EnumMembers!T].sort().uniq;
> }
>
> Preferrably both at compile-time and run-time.

Sure, if you can hash the underlying type this should do the trick in linear time: http://melpon.org/wandbox/permlink/Rvq60fv7jOIPuhXz