We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


Tests if the vector is empty.

bool empty( ) const;

true if the vector is empty; false if the vector is not empty.

// 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;
      cout << "The vector is not empty." << endl;
The vector is not empty.

Header: <vector>

Namespace: std