Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Viewed less than a minute ago

6niHTtIE20NbZZfd

C++ gcc 12.1.0

Created at 4 minutes ago

Created by anonymous

Author

anonymous

4 minutes ago

Language

C++

Compiler

gcc 12.1.0

Options
Warnings
Optimization
Don't Use Boost
C++11
-pedantic
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D

Author

anonymous

4 minutes ago

›
⌄
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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
prog.cc: In function 'int main()':
prog.cc:8:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::unordered_map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |         for (int i = 0; i < hash.size(); i++) {
      |                         ~~^~~~~~~~~~~~~
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
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D