http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49058
--- Comment #15 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 22:30:55 UTC --- This is something which actually passes the testsuite, and the tests here and the new test explained by Jon. Maybe something even more clean along the same lines is possible, but I would be already pretty happy for now... assuming Jon isn't able to figure out yet another regression ;) //////////////////// Index: include/std/functional =================================================================== --- include/std/functional (revision 174044) +++ include/std/functional (working copy) @@ -1210,7 +1210,8 @@ // Call as const template<typename... _Args, typename _Result - = decltype( std::declval<const _Functor>()( + = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0), + typename add_const<_Functor>::type, void>::type>()( _Mu<_Bound_args>()( std::declval<const _Bound_args&>(), std::declval<tuple<_Args...>&>() )... ) )> _Result @@ -1223,7 +1224,8 @@ // Call as volatile template<typename... _Args, typename _Result - = decltype( std::declval<volatile _Functor>()( + = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0), + typename add_volatile<_Functor>::type, void>::type>()( _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(), std::declval<tuple<_Args...>&>() )... ) )> _Result @@ -1236,7 +1238,8 @@ // Call as const volatile template<typename... _Args, typename _Result - = decltype( std::declval<const volatile _Functor>()( + = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0), + typename add_cv<_Functor>::type, void>::type>()( _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(), std::declval<tuple<_Args...>&>() )... ) )> _Result