Another case like PR 79486, this fails to compile with trunk: #include <functional> struct X { }; const X f(int); struct Y { void operator()(X&&) = delete; int operator()(const X&&); }; auto b = std::bind(Y(), std::bind(f, std::placeholders::_1)); auto i = b(1); x.cc:12:13: error: no match for call to ‘(std::_Bind<Y(std::_Bind<const X (*(std::_Placeholder<1>))(int)>)>) (int)’ auto i = b(1); ^
We need to add && to the arg types in the result_of argument, so that top-level cv qualifiers aren't lost in the function type that result_of requires us to use: --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -502,7 +502,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) template<typename _Fn, typename _CallArgs, typename... _BArgs> using _Res_type_impl - = typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>...) >::type; + = typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type; template<typename _CallArgs> using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>; This would be fixed by adopting the proposed invoke_result and using that instead of result_of, which we've agreed to deprecate.
Author: redi Date: Thu Mar 2 03:43:36 2017 New Revision: 245827 URL: https://gcc.gnu.org/viewcvs?rev=245827&root=gcc&view=rev Log: PR 79798 Fix incorrect use of std::result_of in std::bind PR libstdc++/79798 * include/std/functional (bind::_Res_type_impl): Fix incorrect use of result_of that loses top-level cv-qualifiers. * testsuite/20_util/bind/79798.cc: New test. Added: trunk/libstdc++-v3/testsuite/20_util/bind/79798.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/functional
Fixed