Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,913 questions

51,845 answers

573 users

How to clear deque by popping elements in C++

1 Answer

0 votes
#include <iostream> 
#include <deque> 

int main() 
{ 
    std::deque<double> dq = {3.14, 2.18, 4.19, 6.17, 8.27, 5.28}; 

    while(dq.size() > 0) {
        std::cout << "pop: " << dq.front() << "\n";
        dq.pop_front();
    }
    
    if (dq.empty()) {
        std::cout << "empty";
    }
}

      
      
      
/*
run:
      
pop: 3.14
pop: 2.18
pop: 4.19
pop: 6.17
pop: 8.27
pop: 5.28
empty
  
*/

 



answered Feb 25, 2023 by avibootz

Related questions

1 answer 143 views
143 views asked Jul 22, 2020 by avibootz
1 answer 145 views
1 answer 219 views
219 views asked Aug 1, 2020 by avibootz
1 answer 162 views
1 answer 155 views
2 answers 1,257 views
1,257 views asked Jul 21, 2020 by avibootz
2 answers 177 views
...