Я обновляю некоторые элементы (выбранные во время компиляции) в контейнере, используя значения из другого контейнера. Сейчас я делаю что-то похожее на это:
template<size_t... indices>
void update(value_t values, index_sequence<indices...>) {
int i = 0;
((data[indices] = values[i++], ...);
}
Вопрос: можно ли избежать использования переменной i
, используя другую последовательность времени компиляции, например, что-то вроде следующего:
template<size_t... indices1, size_t... indices2>
void update_helper(value_t values, index_sequence<indices1...>,
index_sequence<indices2...>) {
static_assert(sizeof...(indices1) == sizeof...(indices2), "");
((data[indices1] = values[indices2], ...);
}
template<size_t... indices>
void update(value_t values, index_sequence<indices...> i) {
update_helper(values, i, make_index_sequence<sizeof...(indices)>{});
}