Uzywając pętlę for, tak samo jak po innych kontenerach:
int tab[5];
for (int x : tab) cout << x << "\n"; // lub:
for (int &x : tab) cout << x << "\n"; // lub:
for (auto &x : tab) cout << x << "\n"; // lub z const:
for (const auto &x : tab) cout << x << "\n";
std::vector<int> vec;
for (int x : vec) cout << x << "\n";
for (auto &x : vec) cout << x << "\n";
std::map<std::string, int> map;
for (auto &x : map) cout << x.first << ", " << x.second << "\n"; // klucz, wartosc
for (auto &[key, value] : map) cout << key << ", " << value << "\n";
std::unordered_map<std::string, int> hashmap;
for (auto &x : hashmap) cout << x.first << ", " << x.second << "\n"; // klucz, wartosc
for (auto &[key, value] : hashmap) cout << key << ", " << value << "\n";