gcc has a very nice extension in C that allows you to keep data in arrays using enum as keys:
enum keys { key_alpha = 0, key_beta = 1, key_gamma = 2 }; ValType values = { [ key_alpha ] = { 0x03b1,"alpha" }, [ key_gamma ] = { 0x03b3,"gamma" }, [ key_beta ] = { 0x03b2,"beta" } };
This is nice because if the list has to change, adding or removing a line doesn't destroy the assignment, it is obvious which key corresponds to which value, and results in simple code no different from plain standard array initialization.
Unfortunately, this extension is not available in g++.
What would be the preferred lightweight way of doing the same thing in C++? Preferably something not based on <map> and the likes that use string keys, hidden indices, heavy templates or other CPU- and memory-heavy stuff?