关于快读
  • 板块灌水区
  • 楼主WarningQAQ
  • 当前回复2
  • 已保存回复2
  • 发布时间2020/12/2 21:09
  • 上次更新2023/11/5 06:51:25
查看原帖
关于快读
269295
WarningQAQ楼主2020/12/2 21:09
#include"cstdio"
#include"cctype"
#include"typeinfo"
char buffer[1<<28],*S=buffer,puffer[1<<28],*T=puffer;
struct reader{
	typedef long long ll;
	typedef unsigned long long ull;
	typedef unsigned u;
	template<typename ST>
	reader operator>>(ST&x){
		if(typeid(x)==typeid(int)||typeid(x)==typeid(ll)||typeid(x)==typeid(u)||typeid(x)==typeid(ull)){
			int f=0;x=0;
			while(!isdigit(*S))f|=(*S++=='-');
			while(isdigit(*S))x=(x<<3)+(x<<1)+(*S++^48);
			x=f?-x:x;
		}
		else if(typeid(x)==typeid(char)){
			while(isspace(*S))S++;
			x=*S++;
		}
		return*this;
	}
	template<typename ST>
	reader operator<<(ST x){
		if(typeid(x)==typeid(int)||typeid(x)==typeid(ll)||typeid(x)==typeid(u)||typeid(x)==typeid(ull)){
			int num[30],sp=0;
			if(x<0)*T++='-',x=-x;
			if(!x)*T++=48;
			while(x)num[++sp]=x%10,x/=10;
			while(sp)*T++=num[sp--]+48;
		}
		else if(typeid(x)==typeid(char)){
			*T++=x;
		}
		return*this;
	}
}read;

这个template怎么搞字符串类型?

2020/12/2 21:09
加载中...