title: Differences between C++ string == and compare()?
body: <p>I just read some recommendations on using </p>
  
  <pre><code>std::string s = get_string();
  std::string t = another_string();
  
  if( !s.compare(t) ) 
  {
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>if( s == t )
  {
  </code></pre>
  
  <p>I'm almost always using the last one because I'm used to it and it feels natural, more readable. I didn't even know that there was a separate comparison function.
  To be more precise, I thought == would call compare().</p>
  
  <p><strong>What are the differences? In which contexts should one way be favored to the other?</strong></p>
  
  <p>I'm considering only the cases where I need to know if a string is the same value as another string.</p>