RT。
众所周知,在结构体中声明变量需要进行繁杂的内存对齐。
对于如下代码:
struct hashtable{
const int mod = 2e7 + 3, base = 503;
pair <ll, int> umap[20000010];
} T;
一部分编译器显示 out of memory,一部分编译器疑似死循环(比如我的 GCC9.2),或者也可能是编译时间过长。
然而:
struct hashtable{
const int mod = 2e7 + 3,base = 503;
ll umap[20000010];
} T;
struct hashtable{
const int mod = 2e7 + 3,base = 503;
ll umap[20000010];
int um[20000010];
} T;
struct hashtable{
const int mod = 2e7 + 3,base = 503;
int um[80000040];
} T;
都可以在相当快的时间内完成编译。
这是 pair 的对齐方式的问题吗?