My while loop conditions aren't evaluating them as I'm expecting : <p>I'm trying to make an input validation function that checks to see if cin fails (this works fine) and I'm trying to also make it check to see if it's within the min max range that I pass by variable to the function. </p>

<p>I've already tried messing around with different conditions and evaluating it by hand but it seems that either I'm missing some small minutia of the while loop or something total different.</p>

<pre><code>void isValid(int &amp;value, std::string message, int min, int max) {
    while(((std::cout &lt;&lt; message) &amp;&amp; !(std::cin &gt;&gt; value)) &amp;&amp; ((value &gt;= min) &amp;&amp; (value &lt;= max))) {
        std::cout &lt;&lt; "Error with input" &lt;&lt; std::endl;
        std::cin.clear();
        std::cin.ignore(std::numeric_limits&lt;int&gt;::max(), '\n'); }
</code></pre>

<p>I expect the output of isValid(-1, "Enter the test score: ", 0, 100) to keep asking for a valid input, but it accepts it as is.</p>
