Trim a string with C++ [二]

Trim a string with C++ [2]Ive wrote a blog to discuss how to trim a string in C. Now I find an oth

Trim a string with C++ [2]

I've wrote a blog to discuss how to trim a string in C++. Now I find an other way in high performance, see the implements below: 

#include <string>#define  STRING_TRIM_DROPS    " \t"std::string& trim(std::string &s){    static std::string drops = STRING_TRIM_DROPS;  // A char list specifies which characters should be trimmed.    if (s.empty())    {        return s;    }    s.erase(0, s.find_first_not_of(drops));    s.erase(s.find_last_not_of(drops) + 1);    return s;}

Yes, using string::erase() method is the fastest way I ever met.