Compartilhar via


set::empty

Tests if a set is empty.

bool empty( ) const;

Return Value

true if the set is empty; false if the set is nonempty.

Example

// set_empty.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1, s2;
   s1.insert ( 1 );

   if ( s1.empty( ) )
      cout << "The set s1 is empty." << endl;
   else
      cout << "The set s1 is not empty." << endl;

   if ( s2.empty( ) )
      cout << "The set s2 is empty." << endl;
   else
      cout << "The set s2 is not empty." << endl;
}
The set s1 is not empty.
The set s2 is empty.

Requirements

Header: <set>

Namespace: std

See Also

Reference

set Class

set::empty and set::clear

Standard Template Library

Other Resources

set Members