cesium-native 0.57.0
Loading...
Searching...
No Matches
transformTuple.h
1#include <cstddef>
2#include <tuple>
3
4namespace CesiumUtility {
5
17template <typename Tuple, typename Func>
18auto transformTuple(Tuple&& tuple, Func&& f) {
19 constexpr size_t N = std::tuple_size_v<std::remove_reference_t<Tuple>>;
20
21 return [&]<size_t... Is>(std::index_sequence<Is...>) {
22 // Use brace-initialization to guarantee arguments are evaluated in order.
23 // This is not generally guaranteed by "ordinary" function invocation. For
24 // example, func(funcA(), funcB()) could have funcA() _or_ funcB() called
25 // first; the order is unspecified.
26 std::tuple result{
27 std::forward<Func>(f)(std::get<Is>(std::forward<Tuple>(tuple)))...};
28 return result;
29 }
30 (std::make_index_sequence<N>{});
31}
32
33} // namespace CesiumUtility
Utility classes for Cesium.
auto transformTuple(Tuple &&tuple, Func &&f)
Transforms each element of a tuple by applying a function to it.