From a26fdb0946226a6d160cc5e23a2ecdc05c76b2e0 Mon Sep 17 00:00:00 2001 From: Alexander Puck Neuwirth Date: Sat, 1 Apr 2023 08:55:11 +0200 Subject: [PATCH 1/2] Update utils.h --- src/utils/utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/utils.h b/src/utils/utils.h index 9f13365..3db5e65 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -19,8 +19,9 @@ #include #include #include -#include "options.h" +#include +#include "options.h" #include "miniz/miniz.h" /** From b96030e23b1d88fa108962cb7b1f8acb7dd295c3 Mon Sep 17 00:00:00 2001 From: Alexander Puck Neuwirth Date: Sat, 13 May 2023 11:45:52 +0200 Subject: [PATCH 2/2] 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