title: How do I deal with the max macro in windows.h colliding with max in std?
body: <p>So I was trying to get valid integer input from cin, and used an answer to this <a href="https://stackoverflow.com/questions/5864540/a-simple-question-about-cin/5864560#comment15263994_5864560">question</a>.</p>
  
  <p>It recommended:</p>
  
  <pre><code>#include &lt;Windows.h&gt; // includes WinDef.h which defines min() max()
  #include &lt;iostream&gt;
  using std::cin;
  using std::cout;
  
  void Foo()
  {
      int delay = 0;
      do
      {
          if(cin.fail())
          {
              cin.clear();
              cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
          }
          cout &lt;&lt; "Enter number of seconds between submissions: ";
      } while(!(cin &gt;&gt; delay) || delay == 0);
  }
  </code></pre>
  
  <p>Which gives me an error on Windows, saying that the <code>max</code> macro doesn't take that many arguments. Which means I have to do this</p>
  
  <pre><code>do
  {
      if(cin.fail())
      {
          cin.clear();
  #undef max
          cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
      }
      cout &lt;&lt; "Enter number of seconds between submissions: ";
  } while(!(cin &gt;&gt; delay) || delay == 0);
  </code></pre>
  
  <p>To get it to work. That's pretty ugly; is there a better way to work around this issue? Maybe I should be storing the definition of <code>max</code> and redefining it afterward?</p>