#include <cstdio>
#include <iostream>
using ll=long long;
constexpr int N=4e5+5;
template<typename T,int max_size,int page_size>
class MemoryPool{
T pool[max_size*page_size],*stk[max_size],**top;
public:
MemoryPool():top(stk+max_size){
std::cerr<<"Start: "<<top<<std::endl;
int i=0;
for(T*&x:stk)x=pool+page_size*(i++);
}
T*alloc(){
std::cerr<<"Alloc: "<<top<<std::endl;
return *--top;
}
void free(T*p){*top++=p;}
};
template<int n,int base>
class lll{
static MemoryPool<int,10,n>mp;
int *a,len;
public:
lll():a(mp.alloc()),len(0){}
~lll(){mp.free(a);}
};
template<int n,int base>
MemoryPool<int,10,n>lll<n,base>::mp;
lll<N,10>a;
int main(){
return 0;
}
rt,本来想写个高精的,结果a的构造函数比mp的构造函数先调用,导致top还没被初始化就被alloc()调用了