Comment puis-je obtenir g ++ pour effectuer des vérifications de type sur typedefs? C'est possible? à savoirtypedef vérification de type?
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?
Je ne peux pas utiliser C++ 0x caractéristiques (je ne sais pas s'ils peuvent le faire.)
EDIT: Ce que je veux quelque chose comme ceci:
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
Est-ce trop demander?
Je suis presque c'est un dup, mais je ne peux pas trouver l'original. –
Aucun 'typedef', malgré son nom, ne définit pas un nouveau type, il crée juste un alias pour un type existant. – sbi