Applying a function to each element of a tuple
问题 Given an std::tuple -like object (i.e. with defined tuple_size and get semantics) and a unary functor object ftor , I want to be able to call ftor on each element of the tuple -like object. If I disregard the return value, I am aware of the int array trick: namespace details { template <typename Ftor, typename Tuple, size_t... Is> void apply_unary(Ftor&& ftor, Tuple&& tuple, std::index_sequence<Is...>) { using std::get; int arr[] = { (ftor(get<Is>(std::forward<Tuple>(tuple))), void(), 0)... }