title: Efficient way to check if std::string has only spaces
body: <p>I was just talking with a friend about what would be the most efficient way to check if a std::string has only spaces. He needs to do this on an embedded project he is working on and apparently this kind of optimization matters to him.</p>
  
  <p>I've came up with the following code, it uses <code>strtok()</code>.</p>
  
  <pre><code>bool has_only_spaces(std::string&amp; str)
  {
      char* token = strtok(const_cast&lt;char*&gt;(str.c_str()), " ");
  
      while (token != NULL)
      {   
          if (*token != ' ')
          {   
              return true;
          }   
      }   
      return false;
  }
  </code></pre>
  
  <p>I'm looking for feedback on this code and more efficient ways to perform this task are also welcome.</p>