title: How to loop std::set with custom .begin() and .end()?
body: <p>if I have a set for example, with the following content: <code>0,1,2,3,8,13,56,532</code>,</p>
  
  <p>how would I do a <code>for(auto it = xxxxx; y ? z; ++it)</code> from 3 to 532 to 0 to 3 ?</p>
  
  <p>Like:</p>
  
  <pre><code>magic.start(3);
  for(auto i: magic)
      std::cout &lt;&lt; i &lt;&lt; " ";
  </code></pre>
  
  <p>That would print:</p>
  
  <pre><code>3 8 13 56 532 0 1 2
  </code></pre>
  
  <p>Edit: Might anyone be interested in the end result (thanks for all the answers):</p>
  
  <pre><code>bool SpectateNextPlayer(int playerid)
  {
      if (PlayerCurrentlySpectating[playerid] == INVALID_PLAYER_ID)
          return false;
  
      auto current = PlayersOnline.find(PlayerCurrentlySpectating[playerid]);
  
      for (auto it = current; it != PlayersOnline.end(); ++it)
          if (PlayerSpactatable(*it) &amp;&amp; (*it) != PlayerCurrentlySpectating[playerid])
              if (PlayerSpectateOtherPlayer(playerid, *it))//check here if playerid != *it
                  return true;
  
      for (auto it = PlayersOnline.begin(); it != current; ++it)
          if (PlayerSpactatable(*it) &amp;&amp; (*it) != PlayerCurrentlySpectating[playerid])
              if (PlayerSpectateOtherPlayer(playerid, *it))
                  return true;
  
      return !DisablePlayerSpectate(playerid);
  }
  
  bool SpectatePreviousPlayer(int playerid)
  {   
      if (PlayerCurrentlySpectating[playerid] == INVALID_PLAYER_ID)
          return false;
  
      auto rcurrent = find(PlayersOnline.rbegin(), PlayersOnline.rend(), PlayerCurrentlySpectating[playerid]);
  
      for (auto it = rcurrent; it != PlayersOnline.rend(); ++it)
          if (PlayerSpactatable(*it) &amp;&amp; (*it) != PlayerCurrentlySpectating[playerid])
              if (PlayerSpectateOtherPlayer(playerid, *it))
                  return true;
  
      for (auto it = PlayersOnline.rbegin(); it != rcurrent; ++it)
          if (PlayerSpactatable(*it) &amp;&amp; (*it) != PlayerCurrentlySpectating[playerid])
              if (PlayerSpectateOtherPlayer(playerid, *it))
                  return true;
  
      return !DisablePlayerSpectate(playerid);
  }
  </code></pre>