Strong typedefs [duplicate]

Quoting cplusplus.com,

Note that neither typedef nor using create new distinct data types.
They only create synonyms of existing types.
That means that the type
of myword above, declared with type WORD, can as well be considered of
type unsigned int; it does not really matter, since both are actually
referring to the same type.

Since int and handle are one and the same, the output 0 1 is expected.

There’s a workaround though, as @interjay suggests.

You can use BOOST_STRONG_TYPEDEF.

BOOST_STRONG_TYPEDEF( int , handle );

Leave a Comment