From d2738b60e2dfa255e504247f2b5009bc1dc24954 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 24 Jan 2023 13:34:42 -0500 Subject: DRTVWR-558: Fix const-ness glitch in LL::apply(func, tuple) std::get(const tuple) injects const into the type of each returned tuple element. Need to get a non-const ref to the tuple param to get the true type. (cherry picked from commit 6dda39065d3ee231998cb8a2896f94e8a45c9a82) --- indra/llcommon/apply.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/apply.h b/indra/llcommon/apply.h index 123813bcec..0009dd1f80 100644 --- a/indra/llcommon/apply.h +++ b/indra/llcommon/apply.h @@ -74,7 +74,7 @@ template::type = 0 > auto invoke(Fn&& f, Args&&... args) { - return std::mem_fn(f)(std::forward(args)...); + return std::mem_fn(std::forward(f))(std::forward(args)...); } template auto apply_impl(CALLABLE&& func, const std::tuple& args, std::index_sequence) { + // We accept const std::tuple& so a caller can construct an tuple on the + // fly. But std::get(const tuple) adds a const qualifier to everything + // it extracts. Get a non-const ref to this tuple so we can extract + // without the extraneous const. + auto& non_const_args{ const_cast&>(args) }; + // call func(unpacked args) - return invoke(std::forward(func), std::get(args)...); + return invoke(std::forward(func), + std::forward(std::get(non_const_args))...); } template -- cgit v1.2.3