How to check whether a vector is empty in C++ 17

1 Answer

0 votes
#include <iostream>
#include <vector>
 
int main() 
{
    std::vector<int> v = { 5, 3, 1, 8, 2 };

    v.clear();
    if (std::empty(v))
        std::cout << "Empty\n";
}
 


 
/*
run:
 
Empty
 
*/

 



answered Jun 21, 2020 by avibootz

Related questions

1 answer 279 views
1 answer 175 views
1 answer 191 views
191 views asked Apr 22, 2022 by avibootz
1 answer 116 views
1 answer 202 views
1 answer 258 views
1 answer 200 views
...