On Wednesday, 1 September 2021 at 12:32:36 UTC, Steven Schveighoffer wrote:
> >With the implicit opCast
/constructor approach (or the opHeadMutable
approach), the compiler doesn't have to understand the relationships. It just needs to know the original type and the desired type, and call the appropriate user-defined function to perform the conversion.
It just means you need to handle all the implicit conversions, which is not trivial. The compiler already has rules for implicit const conversions, some of which have subtle pitfalls if you get them wrong. I'd rather utilize those mechanisms rather than relying on each type author to get them all right.
As long as the type author does not use unsafe casts, the compiler will prevent them from getting the conversions wrong.