public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR 70564 disambiguate constructors for not_fn call wrapper
Date: Wed, 05 Oct 2016 12:43:00 -0000	[thread overview]
Message-ID: <20161005124248.GO29482@redhat.com> (raw)
In-Reply-To: <20161005113116.GA31323@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

On 05/10/16 12:31 +0100, Jonathan Wakely wrote:
>Tested powerpc64le-linux, committing to trunk and gcc-6-branch.

And here's the slightly diffeernt patch for the branch (because we
only have experimental::not_fn there, not std::not_fn).



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2308 bytes --]

commit 2484aeb5b25372c3a7833a000b798e3bf6f41c6b
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Oct 5 12:01:36 2016 +0000

    PR 70564 disambiguate constructor for not_fn call wrapper
    
    	PR libstdc++/70564
    	* include/experimental/functional (_Not_fn): Add second parameter to
    	disambiguate copying from initialization by not_fn.
    	(not_fn): Add second argument to initialization.
    	* testsuite/experimental/functional/not_fn.cc: Copy call wrapper using
    	direct-initialization. Test abstract class.

diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional
index 0b91dcd..6a21caf 100644
--- a/libstdc++-v3/include/experimental/functional
+++ b/libstdc++-v3/include/experimental/functional
@@ -387,7 +387,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       template<typename _Fn2>
 	explicit
-	_Not_fn(_Fn2&& __fn) : _M_fn(std::forward<_Fn2>(__fn)) { }
+	_Not_fn(_Fn2&& __fn, int) : _M_fn(std::forward<_Fn2>(__fn)) { }
 
       _Not_fn(const _Not_fn& __fn) = default;
       _Not_fn(_Not_fn&& __fn) = default;
@@ -431,7 +431,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
     {
       using __maybe_type = _Maybe_wrap_member_pointer<std::decay_t<_Fn>>;
-      return _Not_fn<typename __maybe_type::type>{std::forward<_Fn>(__fn)};
+      return _Not_fn<typename __maybe_type::type>{std::forward<_Fn>(__fn), 0};
     }
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/testsuite/experimental/functional/not_fn.cc b/libstdc++-v3/testsuite/experimental/functional/not_fn.cc
index 3096eaa..b69d3ac 100644
--- a/libstdc++-v3/testsuite/experimental/functional/not_fn.cc
+++ b/libstdc++-v3/testsuite/experimental/functional/not_fn.cc
@@ -76,10 +76,30 @@ test03()
   VERIFY( not_fn(&X::b)(x) );
 }
 
+void
+test04()
+{
+  struct abstract { virtual void f() = 0; };
+  struct derived : abstract { void f() { } };
+  struct F { bool operator()(abstract&) { return false; } };
+  F f;
+  derived d;
+  VERIFY( not_fn(f)(d) );
+}
+
+void
+test05()
+{
+  auto nf = std::experimental::not_fn([] { return false; });
+  auto copy(nf); // PR libstdc++/70564
+}
+
 int
 main()
 {
   test01();
   test02();
   test03();
+  test04();
+  test05();
 }

      parent reply	other threads:[~2016-10-05 12:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 11:31 Jonathan Wakely
2016-10-05 12:40 ` Jonathan Wakely
2016-10-05 12:43 ` Jonathan Wakely [this message]

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=20161005124248.GO29482@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.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).