Convert C++11 style loop to C++99 style loop