Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <functional>
- #include <tuple>
- #include <type_traits>
- #include <utility>
- namespace details {
- template<typename Tuple, typename Callable, std::size_t... Indexes>
- void for_each_element(Tuple&& tuple, Callable&& callable, std::index_sequence<Indexes...>) {
- (std::invoke(std::forward<Callable>(callable), std::get<Indexes>(std::forward<Tuple>(tuple))), ...);
- }
- }
- template<typename Tuple, typename Callable>
- void for_each_element(Tuple&& tuple, Callable&& callable) {
- using index_sequence = std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>;
- details::for_each_element(std::forward<Tuple>(tuple), std::forward<Callable>(callable), index_sequence{});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement