[libcxx-commits] [PATCH] D140731: [libc++][CI] Fixes robust against ADL for C++03.
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jan 1 09:26:25 PST 2023
philnik added a comment.
In D140731#4021229 <https://reviews.llvm.org/D140731#4021229>, @Mordante wrote:
> In D140731#4020155 <https://reviews.llvm.org/D140731#4020155>, @philnik wrote:
>
>> Where does this fire? `noexcept(cond)` should never be used in C++03.
>
> `include/__functional/invoke.h` lines 431 and 438 are the only two places
>
> template <class _Ret, class _Fp, class ..._Args>
> struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
> {
> typedef __nothrow_invokable_r_imp _ThisT;
>
> template <class _Tp>
> static void __test_noexcept(_Tp) _NOEXCEPT;
>
> static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( // 431
> _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
> };
>
> template <class _Ret, class _Fp, class ..._Args>
> struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
> {
> static const bool value = noexcept( / 438
> _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
> };
IMO we should fix the code here. In C++03 the values are always false anyways, so we could just make this
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
{
typedef __nothrow_invokable_r_imp _ThisT;
template <class _Tp>
static void __test_noexcept(_Tp) _NOEXCEPT;
#ifdef _LIBCPP_CXX03_LANG
static const bool value = false;
#else
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
#endif
};
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
#ifdef _LIBCPP_CXX03_LANG
static const bool value = false;
#else
static const bool value = noexcept(_VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
#endif
};
or something similar.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140731/new/
https://reviews.llvm.org/D140731
More information about the libcxx-commits
mailing list