list::empty

如果列表为空,测试。

bool empty( ) const;

返回值

true,如果列表为空; false,如果列表不为空。

示例

// list_empty.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( )
{
   using namespace std;
   list <int> c1;

   c1.push_back( 10 );
   if ( c1.empty( ) )
      cout << "The list is empty." << endl;
   else
      cout << "The list is not empty." << endl;
}
  

要求

标头: <list>

命名空间: std

请参见

参考

list Class

标准模板库