On 12/18/14 10:43 AM, Steven Schveighoffer wrote:
struct KeyValuePair(K, V) { K key; V value; enum length = 2; ref K opTupleIndex(int x) if(x == 0) { return key;} ref V opTupleIndex(int x) if(x == 1) { return value;} }
Or with more recent changes to the compiler:
template opTupleIndex(int x) if (x == 0) { alias opTupleIndex = key;}
template opTupleIndex(int x) if (x == 1) { alias opTupleIndex = value;}
-Steve
