C++: is string.empty() always equivalent to string == “”?

前端 未结 7 1730
灰色年华
灰色年华 2020-12-28 12:18

Can I make an assumption that given

std::string str;
... // do something to str

Is the following statement is always true?

         


        
7条回答
  •  醉梦人生
    2020-12-28 12:43

    Yes it is equivalent but allows the core code to change the implementation of what empty() actually means depending on OS/Hardware/anything and not affect your code at all. There is similiar practice in Java and .NET

提交回复
热议问题