In my application, I have a type responsible for computing, which (may) include large numbers, and a type that is used for communication between processors.
typedef MyBigIntegerClass bigInt; typedef int smallInt;
The communication part is not compatible with MyBigIntegerClass, therefore, before the message, for example, the vector bigInts, it must be converted to smallints. So far, no problem.
However, for most problematic cases, the use of MyBigIntegerClass is not required. In fact, even int32_t enough. This is why I allow configuration like
typedef int32_t bigInt; typedef int16_t smallInt;
The bigInt type is still large enough for computation. The problem is that smallInt should be different from bigInt.
class Problematic { public: Problematic(bigInt); Problematic(smallInt); };
In this class, constructors or methods can either accept bigInts or smallInts. If they match, compilation fails.
Because other code users may want to adjust the types used, they may end up with a configuration such as
typedef int32_t bigInt; typedef int32_t smallInt;
and compilation is not performed in (at least for some developers) in an unobvious way.
One way to handle this would be static_assert(sizeof(bigInt) != sizeof(smallint), "bad config..") , but I really like the ability to have bigInt == smallInt . What would be a good way to modify a class Problematic declaration to allow type equivalence?