From 3b46c892719ced98cdb3265801cd5f62353b3ced Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 13 Jul 2023 16:01:56 -0400 Subject: 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 0009dd1f80..cf6161ed50 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 +auto apply(CALLABLE&& func, const std::tuple& args) +{ + return std::apply(std::forward(func), args); +} #else // C++14 @@ -124,6 +131,8 @@ auto apply(CALLABLE&& func, const std::tuple& args) std::index_sequence_for{}); } +#endif // C++14 + // per https://stackoverflow.com/a/57510428/5533635 template auto apply(CALLABLE&& func, const std::array& args) @@ -131,8 +140,6 @@ auto apply(CALLABLE&& func, const std::array& args) return apply(std::forward(func), std::tuple_cat(args)); } -#endif // C++14 - /***************************************************************************** * bind_front() *****************************************************************************/ -- cgit v1.2.3