|
Even more modern, we are getting C++26 nowadays. CTADs for vector (no need for explicit string), ranges enumeration, and range-based for-loop with structured types int main() {
vector vec = {
"the", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog"
};
for (auto&& [i, it] : vec | std::views::enumerate)
println ("{}:{}", ++i, it);
}
Compiler explorer example, https://cpp.godbolt.org/z/3r8rPdjbG |