public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] util.cxx: avoid use of ptr_fun removed in c++17
@ 2022-01-18  8:49 Sergei Trofimovich
  0 siblings, 0 replies; only message in thread
From: Sergei Trofimovich @ 2022-01-18  8:49 UTC (permalink / raw)
  To: systemtap; +Cc: Sergei Trofimovich

Without the change systemtap build fails on weekly gcc-12 as:

    util.cxx: In function 'void ltrim(std::string&)':
    util.cxx:1766:56: error: 'std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg))
      [with _Arg = int; _Result = int]' is deprecated: use 'std::mem_fn' instead [-Werror=deprecated-declarations]
     1766 |                        std::not1(std::ptr_fun<int, int>(std::isspace))));
          |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

The change uses lambda to express the predicate.
---
 util.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util.cxx b/util.cxx
index c20f76003..13a5ba7e6 100644
--- a/util.cxx
+++ b/util.cxx
@@ -1763,7 +1763,7 @@ ltrim(std::string &s)
 {
   s.erase(s.begin(),
 	  std::find_if(s.begin(), s.end(),
-		       std::not1(std::ptr_fun<int, int>(std::isspace))));
+		       [](char c){ return !std::isspace(c); }));
 }
 
 // trim from end (in place)
@@ -1771,7 +1771,7 @@ void
 rtrim(std::string &s)
 {
   s.erase(std::find_if(s.rbegin(), s.rend(),
-	  std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
+	  [](char c){ return !std::isspace(c); }).base(), s.end());
 }
 
 // trim from both ends (in place)
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-18  8:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18  8:49 [PATCH] util.cxx: avoid use of ptr_fun removed in c++17 Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).