summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2023-07-13 16:01:56 -0400
committerNat Goodspeed <nat@lindenlab.com>2023-07-13 16:01:56 -0400
commit3b46c892719ced98cdb3265801cd5f62353b3ced (patch)
tree58a09378933e173e37876ee26276ac939e167f0a
parent7d1a3d70373f2988510eccf7dd8f9bd2f6c2694a (diff)
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().
-rw-r--r--indra/llcommon/apply.h13
1 files 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 <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()
*****************************************************************************/