I just read some recommendations on using
std::string s = get_string();
std::string t = another_string();
if( !s.compare(t) )
if( s == t )
I nearly always choose the final one since it feels more natural and readable to me.
I had no idea there was a separate comparison function.
To be more specific, I assumed == would invoke comparison ().
What are the distinctions?
In what circumstances should one approach be preferred over another?
I'm just thinking of scenarios when I need to know if one string has the same value as another.