summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/__functional_036
-rw-r--r--libcxx/include/functional10
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp19
3 files changed, 26 insertions, 9 deletions
diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index 99354834234..13c38d8548d 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -2091,14 +2091,16 @@ public:
result_type
operator()(_Args&& ...__args)
{
- return base::operator()(_VSTD::forward<_Args>(__args)...);
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
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<base const&>(*this), _VSTD::forward<_Args>(__args)...);
}
};
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 7a9d68d3c3d..90972bce7a6 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -2186,12 +2186,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::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<base&>(*this), _VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
@@ -2199,12 +2200,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::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<base const&>(*this), _VSTD::forward<_Args>(__args)...);
}
};
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
index 03447db33de..b7874b77cf0 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
@@ -39,21 +39,34 @@ test_const(const F& f)
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<void>(f));
test(std::bind<void>(&f));
+ test(std::bind<void>(A_void_0()));
+ test_const(std::bind<void>(A_void_0()));
+
+ test(std::bind<void>(g));
+ test(std::bind<void>(&g));
test(std::bind<void>(A_int_0()));
test_const(std::bind<void>(A_int_0()));
}
OpenPOWER on IntegriCloud