代码链接见:https://wandbox.org/permlink/Ex03u0X4YB8zYfpy
C++20的for循环遍历,优雅到爆:
// gcc >=10,
// g++ test.cpp -Wall -Wextra -std=c++2a
#include <iostream>
#include <vector>
using namespace std;
int main()
{
for (std::vector v{1, 2, 3}; auto& e : v) {
std::cout << e;
}
}