Language
C++
Compiler
gcc 12.1.0
Options
Warnings
Optimization
Don't Use Boost
C++11
-pedantic
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<int, int> hash;
hash[1] = 1;
hash[10] = 10;
for (int i = 0; i < hash.size(); i++) {
std::cout << "i = " << i << ", hash.size() = " << hash.size() << '\n';
if (hash[i] == 1) {
std::cout << "hash[i] == 1\n";
}
}
return 0;
}
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.79.0-gcc-12.1.0/include -std=gnu++2b
i = 0, hash.size() = 2
i = 1, hash.size() = 3
hash[i] == 1
i = 2, hash.size() = 3
i = 3, hash.size() = 4
i = 4, hash.size() = 5
i = 5, hash.size() = 6
i = 6, hash.size() = 7
i = 7, hash.size() = 8
i = 8, hash.size() = 9
i = 9, hash.size() = 10
i = 10, hash.size() = 11
Exit Code:
0