title: Overloading increment operator, looping, and edge cases
body: <p>I have an enum, that looks like this:</p>
  
  <pre><code>enum Suit {Clubs, Diamonds, Hearts, Spades};
  </code></pre>
  
  <p>I want to overload the increment operator, so I can easily loop over these four dudes.</p>
  
  <p>When the variable is Clubs, Diamonds, or Hearts there no issue. Its the Spades condition that is giving me a little trouble.</p>
  
  <p>My first instinct was to define it so that when the variable is spades, incrementation sets it equal to Clubs. The problem is that this seems to make it impossible to loop over the 4 values in the enum.</p>
  
  <p>If I do something like</p>
  
  <pre><code>for(Suit i=Clubs;i&lt;Spades;++i)
       {cout&lt;&lt;i&lt;&lt;endl;}
  </code></pre>
  
  <p>then my output only goes to Hearts.</p>
  
  <p>If i do</p>
  
  <pre><code>for(suit i=Clubs;i&lt;=Spades;++i)
      {cout&lt;&lt;i&lt;&lt;endl;}
  </code></pre>
  
  <p>then my output just loops forever!</p>
  
  <p>So, I can obviously think of a few workarounds for this... I'm just not sure what the idiomatic C++ thing do to.</p>
  
  <p>Should I redefine incrementation so that attempting to increment a Spade results in a Spade? or maybe throws an exception? </p>
  
  <p>To reiterate: I can definitely think of a few hacky ways to fix this issue. I just want the guidance of experienced programmers to tell me what they think would be the most "normal" way to solve the problem.</p>