diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2022-12-19 17:27:36 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2023-07-13 12:34:31 -0400 |
commit | 196e49c1f8bd58ab9ce81843c10d452284ca7569 (patch) | |
tree | d7769b713adbbdcc1488cb6dd306c9d240748088 /indra/llcommon/apply.h | |
parent | c682603417e1ef8290aacf274ff49821bd204c0b (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/apply.h')
-rw-r--r-- | indra/llcommon/apply.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/indra/llcommon/apply.h b/indra/llcommon/apply.h index 26753f5017..9f4c268895 100644 --- a/indra/llcommon/apply.h +++ b/indra/llcommon/apply.h @@ -108,7 +108,11 @@ auto apply_impl(CALLABLE&& func, const std::vector<T>& args, std::index_sequence std::make_tuple(args[I]...)); } -// this goes beyond C++17 std::apply() +/** + * apply(function, std::vector) 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, typename T> auto apply(CALLABLE&& func, const std::vector<T>& args) { |