Workaround ICE in MSVC 2015 x64.
MSVC would crash when compiling this inner loop when written with std::transform, so convert it to a for-range loop.
MSVC would crash when compiling this inner loop when written with std::transform, so convert it to a for-range loop.