empty
来自cppreference.com
Syntax:
#include <string> bool empty() const;
The empty() function returns true if the string has no elements, false otherwise. For example:
如果 string 对象没有元素,empty()函数返回 true, 否则返回 false。例如:
string s1; string s2(""); string s3("This is a string"); cout.setf(ios::boolalpha); cout << s1.empty() << endl; cout << s2.empty() << endl; cout << s3.empty() << endl;
When run, this code produces the following output:
运行后,代码会产生如下输出:
true true false
Related Topics: size