public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyich@gmail.com>
To: systemtap@sourceware.org
Cc: Sergei Trofimovich <slyich@gmail.com>
Subject: [PATCH] util.cxx: avoid use of ptr_fun removed in c++17
Date: Tue, 18 Jan 2022 08:49:09 +0000	[thread overview]
Message-ID: <20220118084909.1657330-1-slyich@gmail.com> (raw)

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


                 reply	other threads:[~2022-01-18  8:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220118084909.1657330-1-slyich@gmail.com \
    --to=slyich@gmail.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).