From 3b46c892719ced98cdb3265801cd5f62353b3ced Mon Sep 17 00:00:00 2001 From: Nat Goodspeed <nat@lindenlab.com> Date: Thu, 13 Jul 2023 16:01:56 -0400 Subject: [PATCH] DRTVWR-558: Constrain LL::apply()'s use of std::apply(). Once std::apply() becomes available, 'using std::apply;' isn't correct because the more general template tries to handle the apply(function, vector) case that we explicitly implement below. Have to provide apply(function, tuple) and apply(function, array) signatures that can forward to std::apply(). --- indra/llcommon/apply.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/indra/llcommon/apply.h b/indra/llcommon/apply.h index 0009dd1f801..cf6161ed501 100644 --- a/indra/llcommon/apply.h +++ b/indra/llcommon/apply.h @@ -93,7 +93,14 @@ auto invoke(Fn&& f, Args&&... args) #if __cpp_lib_apply >= 201603L // C++17 implementation -using std::apply; +// We don't just say 'using std::apply;' because that template is too general: +// it also picks up the apply(function, vector) case, which we want to handle +// below. +template <typename CALLABLE, typename... ARGS> +auto apply(CALLABLE&& func, const std::tuple<ARGS...>& args) +{ + return std::apply(std::forward<CALLABLE>(func), args); +} #else // C++14 @@ -124,6 +131,8 @@ auto apply(CALLABLE&& func, const std::tuple<ARGS...>& args) std::index_sequence_for<ARGS...>{}); } +#endif // C++14 + // per https://stackoverflow.com/a/57510428/5533635 template <typename CALLABLE, typename T, size_t SIZE> auto apply(CALLABLE&& func, const std::array<T, SIZE>& args) @@ -131,8 +140,6 @@ auto apply(CALLABLE&& func, const std::array<T, SIZE>& args) return apply(std::forward<CALLABLE>(func), std::tuple_cat(args)); } -#endif // C++14 - /***************************************************************************** * bind_front() *****************************************************************************/ -- GitLab