public member function
<queue>
std::queue::emptyTest whether container is empty
Returns whether the queue is empty: i.e. whether its size is zero.This member function effectively calls member empty of the underlying container object.
true
if the underlying container's size is 0
, false
otherwise.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// queue::empty
#include <iostream> // std::cout
#include <queue> // std::queue
int main ()
{
std::queue<int> myqueue;
int sum (0);
for (int i=1;i<=10;i++) myqueue.push(i);
while (!myqueue.empty())
{
sum += myqueue.front();
myqueue.pop();
}
std::cout << "total: " << sum << '\n';
return 0;
}
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4