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 292 views
1 answer 182 views
1 answer 200 views
200 views asked Apr 22, 2022 by avibootz
1 answer 134 views
1 answer 214 views
1 answer 276 views
1 answer 217 views
...