Given both Lua and python use a enumerator, the C++ example isn't really the correct equivalent.
for (auto [i, v] : std::views::enumerate(vec)) {
std::cout << i << ": " << v << '\n';
}
This is how you'd do it.