[yoda-svn] yoda: StringUtils.h: Replace std::ptr_fun (removed in C++17) wit...

YODA Mercurial yoda at projects.hepforge.org
Wed May 2 17:15:02 BST 2018


details:   https://yoda.hepforge.org/hg/yoda/rev/d28157085e5a
branches:  release-1-7
changeset: 1456:d28157085e5a
user:      Andy Buckley <andy at insectnation.org>
date:      Wed May 02 17:12:32 2018 +0100
description:
StringUtils.h: Replace std::ptr_fun (removed in C++17) with a lambda function. Thanks to Stefan Richter.

diffs (31 lines):

--- a/ChangeLog	Mon Apr 30 22:36:08 2018 +0100
+++ b/ChangeLog	Wed May 02 17:12:32 2018 +0100
@@ -1,3 +1,7 @@
+2018-05-02  Andy Buckley  <andy.buckley at cern.ch>
+
+	* StringUtils.h: Replace std::ptr_fun (removed in C++17) with a lambda function. Thanks to Stefan Richter.
+
 2018-04-30  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Add "-" = stdin/stdout recognition to C++ IO functions.
--- a/include/YODA/Utils/StringUtils.h	Mon Apr 30 22:36:08 2018 +0100
+++ b/include/YODA/Utils/StringUtils.h	Wed May 02 17:12:32 2018 +0100
@@ -98,14 +98,15 @@
 
     /// In-place trim from start
     inline std::string& iltrim(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(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char c){ return !std::isspace(c); }));
+
       return s;
     }
 
     /// In-place trim from end
     inline std::string& irtrim(std::string& s) {
-        s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
-        return s;
+      s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char c){ return !std::isspace(c); }).base(), s.end());
+      return s;
     }
 
     /// In-place trim from both ends


More information about the yoda-svn mailing list