Fix Xcode deprecation warning for std::ptr_fun

Replaced logic in strstrip() with a lambda to avoid deprecations:

- std::ptr_fun is deprecated in C++11, removed C++17
- std::not1 is deprecated in C++17. removed C++20
This commit is contained in:
Jon Siwek 2019-09-26 09:45:44 -07:00
parent 1253a61340
commit bc18ca44e6

View file

@ -701,8 +701,9 @@ string strreplace(const string& s, const string& o, const string& n)
std::string strstrip(std::string s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
auto notspace = [](unsigned char c) { return ! std::isspace(c); };
s.erase(s.begin(), std::find_if(s.begin(), s.end(), notspace));
s.erase(std::find_if(s.rbegin(), s.rend(), notspace).base(), s.end());
return s;
}