From b96030e23b1d88fa108962cb7b1f8acb7dd295c3 Mon Sep 17 00:00:00 2001 From: Alexander Puck Neuwirth Date: Sat, 13 May 2023 11:45:52 +0200 Subject: [PATCH] rm std::ptr_fun --- src/utils/utils.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/utils/utils.h b/src/utils/utils.h index 9f13365..d5e8eb4 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -201,15 +201,22 @@ inline bool parse_boolstring(const std::string &value) { return value == "true"; inline double double_min() { return std::numeric_limits::min(); } -static inline std::string <rim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace)))); - return s; +// trim from start +static inline std::string& ltrim(std::string &s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) + { return !std::isspace(ch); })); + return s; } // trim from end -static inline std::string &rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); - return s; +static inline std::string& rtrim(std::string &s) +{ + s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) + { return !std::isspace(ch); }) + .base(), + s.end()); + return s; } // trim from both ends