diff options
| author | Eric Fiselier <eric@efcs.ca> | 2015-02-10 16:48:45 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2015-02-10 16:48:45 +0000 |
| commit | 54519a6be9296fb115b949f1f0785d9cbfacc7c5 (patch) | |
| tree | d99921a0bd8162f333fba7fe5ecd741c09e89805 /libcxx/include/__functional_base_03 | |
| parent | 51544023a955929cbb3d105421b2e59f6be43964 (diff) | |
| download | bcm5719-llvm-54519a6be9296fb115b949f1f0785d9cbfacc7c5.tar.gz bcm5719-llvm-54519a6be9296fb115b949f1f0785d9cbfacc7c5.zip | |
[libcxx] Fix PR 22468 - std::function<void()> does not accept non-void-returning functions
Summary:
The bug can be found here: http://llvm.org/bugs/show_bug.cgi?id=22468
`__invoke_void_return_wrapper` is needed to properly handle calling a function that returns a value but where the std::function return type is void. Without this '-Wsystem-headers' will cause `function::operator()(...)` to not compile.
Reviewers: eugenis, K-ballo, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D7444
llvm-svn: 228705
Diffstat (limited to 'libcxx/include/__functional_base_03')
| -rw-r--r-- | libcxx/include/__functional_base_03 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libcxx/include/__functional_base_03 b/libcxx/include/__functional_base_03 index 22c06add90f..65502778666 100644 --- a/libcxx/include/__functional_base_03 +++ b/libcxx/include/__functional_base_03 @@ -995,6 +995,63 @@ struct __invoke_return2 _VSTD::declval<_A2>())) type; }; +template <class _Ret> +struct __invoke_void_return_wrapper +{ + template <class _Fn> + static _Ret __call(_Fn __f) + { + return __invoke(__f); + } + + template <class _Fn, class _A0> + static _Ret __call(_Fn __f, _A0& __a0) + { + return __invoke(__f, __a0); + } + + template <class _Fn, class _A0, class _A1> + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) + { + return __invoke(__f, __a0, __a1); + } + + template <class _Fn, class _A0, class _A1, class _A2> + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + return __invoke(__f, __a0, __a1, __a2); + } +}; + + +template <> +struct __invoke_void_return_wrapper<void> +{ + template <class _Fn> + static void __call(_Fn __f) + { + __invoke(__f); + } + + template <class _Fn, class _A0> + static void __call(_Fn __f, _A0& __a0) + { + __invoke(__f, __a0); + } + + template <class _Fn, class _A0, class _A1> + static void __call(_Fn __f, _A0& __a0, _A1& __a1) + { + __invoke(__f, __a0, __a1); + } + + template <class _Fn, class _A0, class _A1, class _A2> + static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + __invoke(__f, __a0, __a1, __a2); + } +}; + template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> |

