Index: include/__functional_03 =================================================================== --- include/__functional_03 +++ include/__functional_03 @@ -2091,14 +2091,16 @@ result_type operator()(_Args&& ...__args) { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } template result_type operator()(_Args&& ...__args) const { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } }; Index: include/functional =================================================================== --- include/functional +++ include/functional @@ -2186,12 +2186,13 @@ typename enable_if < is_convertible >::type, - result_type>::value, + result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } template @@ -2199,12 +2200,13 @@ typename enable_if < is_convertible >::type, - result_type>::value, + result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) const { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } }; Index: test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp =================================================================== --- test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp +++ test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp @@ -39,21 +39,34 @@ void f() {++count;} -struct A_int_0 +int g() {++count; return 0;} + +struct A_void_0 { void operator()() {++count;} void operator()() const {count += 2;} }; +struct A_int_0 +{ + int operator()() {++count; return 4;} + int operator()() const {count += 2; return 5;} +}; + int main() { test(std::bind(f)); test(std::bind(&f)); - test(std::bind(A_int_0())); - test_const(std::bind(A_int_0())); + test(std::bind(A_void_0())); + test_const(std::bind(A_void_0())); test(std::bind(f)); test(std::bind(&f)); + test(std::bind(A_void_0())); + test_const(std::bind(A_void_0())); + + test(std::bind(g)); + test(std::bind(&g)); test(std::bind(A_int_0())); test_const(std::bind(A_int_0())); }