Advertisement
Guest User

for_each_in_tuple

a guest
Jul 23rd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. namespace detail {
  2.     template<class F, class... Ts, std::size_t... Is>
  3.     void for_each_in_tuple(const std::tuple<Ts...> & tuple, F func, std::index_sequence<Is...>){
  4.         using expander = int[];
  5.         (void)expander { 0, ((void)func(std::get<Is>(tuple)), 0)... };
  6.     }
  7. }
  8.  
  9. template<class F, class...Ts>
  10. void for_each_in_tuple(const std::tuple<Ts...> & tuple, F func){
  11.     detail::for_each_in_tuple(tuple, func, std::make_index_sequence<sizeof...(Ts)>());
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement