Situation:
typedef int TypeA;
typedef int TypeB;
I need to make TypeA incompatible with TypeB (so any attempt to assign TypeA to TypeB would trigger compile error), while retaining all functionality provided by built-in type (operators).
One way to do it is to wrap each type into separate struct/class (and redefine all operators, etc).
Is there any other, more "elegant", way to do it?
Third party libraries are not allowed. C++0x/C++11x is not supported. (C++ 2003 is supported)
The only way is to create a new type (by using for example BOOST_STRONG_TYPEDEF).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With