如何让g对typedef进行类型检查?可能吗?即
- typedef int T1;
- typedef int T2;
- T1 x = 5; //Ok with me
- T2 y = x; //Any way to get an error or a warning here?
我不能使用C 0x功能(我不知道他们是否可以这样做.)
编辑:我想要的是这样的:
- typedef int BallID;
- typedef int BatID;
- BatID x = 10;
- map<BatID,Bat*> m;
- m.insert(make_pair(x,bigbat)); //OK
- BallID y = 15;
- m.insert(make_pair(y,smallbat)); //Give me a warning at least plz
这要问太多了吗?