From: Jonathan Wakely Date: Wed, 5 Oct 2016 13:51:03 +0000 (+0100) Subject: PR 70564 disambiguate constructor for not_fn call wrapper X-Git-Tag: releases/gcc-5.5.0~789 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0a6a24656034850a5b216f3dd35108acee32485;p=thirdparty%2Fgcc.git 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. From-SVN: r240790 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4e54c0ca8dfd..4cc7444dfec0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2016-10-05 Jonathan Wakely + 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. + PR libstdc++/77864 * include/bits/stl_map.h (map::map()): Use nothrow constructibility of comparison function in conditional noexcept. diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional index 8d19ad3a79a4..0d0ab3713378 100644 --- a/libstdc++-v3/include/experimental/functional +++ b/libstdc++-v3/include/experimental/functional @@ -384,7 +384,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: template 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; @@ -428,7 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(std::is_nothrow_constructible, _Fn&&>::value) { using __maybe_type = _Maybe_wrap_member_pointer>; - return _Not_fn{std::forward<_Fn>(__fn)}; + return _Not_fn{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 4c137e85bea9..18ea24ee077b 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(); }