diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ad4cdc3fe01..d6fa5319b53 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2016-01-12 Jonathan Wakely + + PR libstdc++/69005 + PR libstdc++/69222 + * include/std/functional (function::_Invoke): Remove, use result_of. + (function::_Callable): Replace alias template with class template + and use partial specialization instead of _NotSelf alias template. + (function(_Functor)): Add "not self" constraint so that _Callable is + not used while type is incomplete. + * testsuite/20_util/function/69222.cc: New. + 2016-01-11 Jonathan Wakely PR libstdc++/60976 diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 8023ab9aa4b..557156a358c 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1846,20 +1846,14 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) { typedef _Res _Signature_type(_ArgTypes...); - template - using _Invoke - = decltype(std::__callable_functor(std::declval<_Functor&>()) - (std::declval<_ArgTypes>()...) ); + template::type> + struct _Callable : __check_func_return_type<_Res2, _Res> { }; // Used so the return type convertibility checks aren't done when // performing overload resolution for copy construction/assignment. template - using _NotSelf = __not_>; - - template - using _Callable - = __and_<_NotSelf<_Functor>, - __check_func_return_type<_Invoke<_Functor>, _Res>>; + struct _Callable : false_type { }; template using _Requires = typename enable_if<_Cond::value, _Tp>::type; @@ -1924,6 +1918,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) * reference_wrapper, this function will not throw. */ template>, void>, typename = _Requires<_Callable<_Functor>, void>> function(_Functor); @@ -2116,7 +2111,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) } template - template + template function<_Res(_ArgTypes...)>:: function(_Functor __f) : _Function_base() diff --git a/libstdc++-v3/testsuite/20_util/function/69222.cc b/libstdc++-v3/testsuite/20_util/function/69222.cc new file mode 100644 index 00000000000..7c9dfecb547 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/69222.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +// Reduced from c++/69005 +struct Foo { + std::function f; +}; + +extern Foo exfoo; +Foo f(exfoo); +Foo& r = f = exfoo;