title: c++ while loop condition isn't playing nice with stack.empty()
body: <p>So I'm flustered by this bit of code - can't understand why it's misbehaving. The only thing I can think of is that stack.empty() isn't working properly with the while loop, but that seems ridiculous. You'll see in the output following the code that the program never makes it out of the while loop before the run fails.</p>
  
  <p>declaration of opStack and newOrder:</p>
  
  <pre><code>queue&lt;string&gt; newOrder;
  stack&lt; vector&lt;char&gt; &gt; opStack;
  </code></pre>
  
  <p>other stuff happens, then this code executes:</p>
  
  <pre><code>while(opStack.empty()==false){
      if(opStack.top()[1] != 'L'){
          cout&lt;&lt;"is stack empty?:"&lt;&lt;opStack.empty()&lt;&lt;endl;
          symbol = opStack.top()[0];
          newOrder.push(symbol);
          opStack.pop();
          cout&lt;&lt;"popped stack;"&lt;&lt;endl;
          cout&lt;&lt;"is stack empty?:"&lt;&lt;opStack.empty()&lt;&lt;endl;
      }
      else{
          break;
      }
  }
  cout&lt;&lt;"made it out of while loop";
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>is stack empty?:0
  popped stack;
  is stack empty?:1
  RUN FAILED (exit value 1, total time: 1s)
  </code></pre>