Last active
March 19, 2025 10:42
-
-
Save pordyna/710b59377b07317696ce3b39003c5f26 to your computer and use it in GitHub Desktop.
Code snippet showing how to define a transform operation on a std tuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename T_Func, typename... T_values, std::size_t... I> | |
| inline auto applyToTupleImpl( | |
| T_Func func, | |
| const std::tuple<T_values...> &tuple, | |
| std::index_sequence<I...>) | |
| { | |
| return std::make_tuple(func(std::get<I>(tuple))...); | |
| } | |
| template <typename T_Func, typename... T_values> | |
| inline auto applyToTuple( | |
| T_Func func, | |
| const std::tuple<T_values...> &tuple) | |
| { | |
| return applyToTupleImpl(func, tuple, std::make_index_sequence<sizeof...(T_values)>{}); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment