title: Initializing enum-indexed array?
body: <p>gcc has a very nice extension in C that allows you to keep data in arrays using enum as keys:</p>
  
  <pre><code> 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" }
   };
  </code></pre>
  
  <p>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.</p>
  
  <p>Unfortunately, this extension is not available in g++. </p>
  
  <p>What would be the preferred lightweight way of doing the same thing in C++? Preferably something not based on &lt;map&gt; and the likes that use string keys, hidden indices, heavy templates or other CPU- and memory-heavy stuff?</p>