how can i clear a stack in c++ efficiently? : <p>I have a c++ stack named pages.
As I have no clear() function to clear a stack, I wrote the following code:</p>

<pre><code>stack&lt;string&gt; pages;
//here is some operation
//now clearing the stack
while(!pages.empty())
    pages.pop();
</code></pre>

<p>Now my question: is there a better efficient way to clear the stack?
Thanks in advance. </p>
