title: C++ enum evaluates to unexpected value
body: <p>I have an enum defined as below so expect it to be returning values between 0-6</p>
  
  <pre><code>enum blocks
  { none = 0, red, green, blue, yellow, white, black };
  
  Grid&lt;blocks&gt; gameGrid; // initialised to none
  </code></pre>
  
  <p>I am trying to use the enum as an offset into an array containing the colours for the blocks. However <code>gameGrid[y][x]</code> is returning a number outside of the range above, causing a segmentation fault.</p>
  
  <pre><code>fixedColor = colourArray[gameGrid[y][x]];
  </code></pre>
  
  <p>I have checked y and x are within range (0-19), gdb reports:</p>
  
  <blockquote>
  <pre><code>(gdb) print y
  $1 = 19
  (gdb) print x
  $2 = 5
  (gdb) print gameGrid[y][x]
  $3 = (blocks &amp;) @0x8201dc4: 136172580
  </code></pre>
  </blockquote>
  
  <p>Below is the definition of the Grid:</p>
  
  <pre><code>template &lt;typename T&gt;
  class Grid
  {
      std::deque&lt;Row&lt;T&gt; &gt; rows;
      T defaultValue;
  
  public:
      const unsigned width, height;
  
      Grid(unsigned inWidth, unsigned inHeight, T inValue) : defaultValue(inValue), width(inWidth), height(inHeight)
      {
          Row&lt;T&gt; r(width, inValue);  
          for (unsigned i = height; i; --i)        
              rows.push_back(r);
      }    
  
      Row&lt;T&gt;&amp; operator[](unsigned arg) { return rows[arg]; }
  </code></pre>
  
  <p>.....</p>
  
  <p>As for Row:</p>
  
  <pre><code>template &lt;typename T&gt;
  class Row
  {
  public:
      std::vector&lt;T&gt; elements;
      Row(unsigned inWidth, T inValue) : elements(inWidth, inValue) {};
      T&amp; operator[](unsigned arg) { return elements[arg]; }    
  </code></pre>
  
  <p>....</p>
  
  <p>And I call:</p>
  
  <pre><code>Game::Game(App&amp; inApp) : theApp(inApp), bgColour(sf::Color::Black), gridWidth(10), gridHeight(20), gameGrid(gridWidth, gridHeight, blocks::none),
  </code></pre>
  
  <p>.....</p>
  
  <p>I am curious as to how a value of the gameGrid of blocks type could evaluate to 136172580.
  Any thoughts on what I am missing would be much appreciated, thank you.</p>