Ответ 1
Не с std::transform
, но ничего, что магия шаблона не может исправить.
template<std::size_t N, std::size_t... Is>
std::array<Bar, N> foos_to_bars(const std::array<Foo, N>& foos,
std::index_sequence<Is...>) {
return {{ Bar(foos[Is].m_1, foos[Is].m_2)... }};
}
template<std::size_t N, std::size_t... Is>
std::array<Bar, N> foos_to_bars(const std::array<Foo, N>& foos) {
return foos_to_bars(foos, std::make_index_sequence<N>());
}
std::index_sequence
, а друзья - это С++ 14, но легко реализуемые в С++ 11. На SO есть, вероятно, полдюжины реализаций.