summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsdutil.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2022-12-19 17:27:36 -0500
committerNat Goodspeed <nat@lindenlab.com>2023-07-13 12:34:31 -0400
commit196e49c1f8bd58ab9ce81843c10d452284ca7569 (patch)
treed7769b713adbbdcc1488cb6dd306c9d240748088 /indra/llcommon/llsdutil.h
parentc682603417e1ef8290aacf274ff49821bd204c0b (diff)
DRTVWR-558: Add unit test for VAPPLY().
Add to apply_test.cpp a collect() function that incrementally accumulates an arbitrary number of arguments into a std::vector<std::string>. Construct a std::array<std::string> to pass it, using VAPPLY(). Clarify in header comments that LL::apply() can't call a variadic function with arguments of dynamic size: std::vector or LLSD. The compiler can deduce how many arguments to pass to a function with a fixed argument list; it can deduce how many arguments to pass to a variadic function with a fixed number of arguments. But it can't compile a call to a variadic function with an arguments data structure whose size can vary at runtime. (cherry picked from commit ceed33396266b123896f7cfb9b90abdf240e1eec)
Diffstat (limited to 'indra/llcommon/llsdutil.h')
-rw-r--r--indra/llcommon/llsdutil.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h
index eaf8825791..eddaa64bd2 100644
--- a/indra/llcommon/llsdutil.h
+++ b/indra/llcommon/llsdutil.h
@@ -31,6 +31,7 @@
#include "llsd.h"
#include <boost/functional/hash.hpp>
+#include <boost/type_traits.hpp>
#include <cassert>
// U32
@@ -601,6 +602,11 @@ auto apply_impl(CALLABLE&& func, const LLSD& array, std::index_sequence<I...>)
return std::forward<CALLABLE>(func)(LLSDParam<LLSD>(array[I])...);
}
+/**
+ * apply(function, LLSD) goes beyond C++17 std::apply(). For this case
+ * @a function @emph cannot be variadic: the compiler must know at compile
+ * time how many arguments to pass. This isn't Python.
+ */
template <typename CALLABLE>
auto apply(CALLABLE&& func, const LLSD& args)
{