typedef type checking?

c++, typedef, types

Solution

Consider using a strong typedef: https://www.boost.org/doc/libs/release/boost/serialization/strong_typedef.hpp

Problem

How do I get g++ to make type checks on typedefs? Is it possible? i.e. ``` 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? ``` I can't use C++0x features (I don't know whether they can do this.) EDIT: What I want is something like this: ``` 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 ``` Is this too much to ask?

Original source

Related problems