indexing stuff during compile time

Eric nil at example.com
Sun Dec 24 21:51:03 UTC 2017


Forgot to mention that I also want groupIndex!(A,B) == 
groupIndex!(B,A)
Which I wanted to do by sorting the names.

If that requirement wasn't there it would be as simple as:


auto groupIndex(Ts...)() {
   return GroupId!Ts.id;
}


size_t s_nextIdx=1;

struct GroupId(Ts ...) {
   static size_t id;

   static this() {
     id = s_nextIdx++;
   }
}





More information about the Digitalmars-d-learn mailing list