Deriving different and incomparable types from int in C++

Viewed 490

I know I cannot derive from an int and it is not even necessary, that was just one (non)solution that came to my mind for the problem below.

I have a pair (foo,bar) both of which are represented internally by an int but I want the typeof(foo) to be incomparable with the typeof(bar). This is mainly to prevent me from passing (foo,bar) to a function that expects (bar, foo). If I understand it correctly, typedef will not do this as it is only an alias. What would be the easiest way to do this. If I were to create two different classes for foo and bar it would be tedious to explicitly provide all the operators supported by int. I want to avoid that.

3 Answers
Related