Christopher Wright wrote:
Charles Hixson wrote:
A) Yes, it works the way that you say.  This damages it's utility.
B) I'm replying to a question as to how typedef could reasonably be extended.

The point of a typedef is to provide additional type safety. This would not exist if you could implicitly cast back and forth. Unless you want an implicit cast from a typedef type to the base type, and not the reverse -- that might be reasonable (I can't immediately see any issues with it).

That's all that's needed to solve the use case that I presented. Unfortunately, what it tried to do was cast it to either byte or long rather than the base case (which was int). Fortunately it couldn't decide which to cast it as, as either choice would have been an error. (I'm writing to a binary file, and the size of the item written is significant.)

Because of this, to avoid scattering casts throughout the program, I had to replace the typedef with alias. This works, but it also definitely prevents the type safety that a typedef could (should) have provided.

Reply via email to