Example:
int main()
{
typedef int Oranges;
typedef int Apples;
/* ... a lot of other code */
Oranges not_apples = 10;
Apples apples = not_apples; // ??? confusing
}
Question: Can we forbid implicit casting for variables which were declared via typedefs?
typedefactually only creates an alias to a base type, so both types you created are actually just aliases toint. What you’re looking for isboost::strong_typedef.