From 6c49e1ce2610171add0132d678981d18d7702d84 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 3 Apr 2019 17:54:37 +0000 Subject: [PATCH] [libc++] Use std::is_nothrow_callable for std::invoke according to LWG 2807 Thanks to Zoe Carver for the patch. Differential Revision: https://reviews.llvm.org/D58097 llvm-svn: 357616 --- libcxx/include/functional | 8 ++++++-- .../function.objects/func.invoke/invoke.pass.cpp | 5 +++-- libcxx/www/cxx1z_status.html | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libcxx/include/functional b/libcxx/include/functional index def8a75f618a..2cec0ea48bc3 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -230,6 +230,10 @@ template template unspecified bind(Fn&&, BoundArgs&&...); +template + invoke_result_t invoke(F&& f, Args&&... args) // C++17 + noexcept(is_nothrow_invocable_v); + namespace placeholders { // M is the implementation-defined number of placeholders extern unspecified _1; @@ -2769,9 +2773,9 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args) #if _LIBCPP_STD_VER > 14 template -result_of_t<_Fn&&(_Args&&...)> +invoke_result_t<_Fn, _Args...> invoke(_Fn&& __f, _Args&&... __args) - noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...))) + noexcept(is_nothrow_invocable_v<_Fn, _Args...>) { return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); } diff --git a/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp index 57350f16c400..0f25db0399fb 100644 --- a/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp @@ -10,8 +10,9 @@ // -// template -// result_of_t invoke(F&&, Args&&...); +// template +// invoke_result_t invoke(F&& f, Args&&... args) // C++17 +// noexcept(is_nothrow_invocable_v<_Fn, _Args...>); /// C++14 [func.def] 20.9.0 /// (1) The following definitions apply to this Clause: diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index 68a5d1ab919a..a4ef75764ae0 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -461,7 +461,7 @@ 2802shared_ptr constructor requirements for a deleterKona 2804Unconditional constexpr default constructor for istream_iteratorKonaComplete 2806Base class of bad_optional_accessKonaComplete - 2807std::invoke should use std::is_nothrow_callableKona + 2807std::invoke should use std::is_nothrow_callableKonaComplete 2812Range access is available with <string_view>KonaComplete 2824list::sort should say that the order of elements is unspecified if an exception is thrownKonaComplete 2826string_view iterators use old wordingKonaComplete