Answer
Yes. Here is the corresponding implementation from bits/basic_string.h , the code for basic_string<_CharT, _Traits, _Alloc> :
bool empty() const { return this->size() == 0; }
Discussion
Even if these two forms are equivalent for std::string , you can use .empty() because it is more general.
Indeed, JF Sebastian notices that if you switch to using std::wstring instead of std::string , then =="" will not even compile, because you cannot compare the wchar_t string with one of char . This, however, is not directly related to your original question, and I'm 99% sure that you will not switch to std::wstring .
A. Rex Jan 27 '09 at 13:17 2009-01-27 13:17
source share