replace for with std::transform