다음을 통해 공유


vector::empty

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

See Also

Reference

vector Class

vector::empty, vector::erase, and vector::push_back

Standard Template Library