Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tests if the vector contains any elements.
bool empty( ) const;
Return Value
true if the vector is empty; false if the vector is not empty.
Example
// vector_empty.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
vector <int> v1;
v1.push_back( 10 );
if ( v1.empty( ) )
cout << "The vector is empty." << endl;
else
cout << "The vector is not empty." << endl;
}
The vector is not empty.
Requirements
Header: <vector>
Namespace: std