I feel this is kind of like cheating. It also makes function overloading somewhat unnecessary. If the overloaded functions are forwarded like this, why not just not overload them in the first place?
This is just typecasting with extra steps, and using opaque types to work around generics seems like an overkill.
I apologize if I come across as criticizing these 2 approaches. It's not my intention. They are solid workarounds to the problem I posted. And I didn't know the 2nd way existed. Thank you for showing me it. However, they are really awkward, not swifty.
Why does 3.14
have to be cast as an opaque type? And why is a typecasting necessary? If the user is allowed to tell the compiler exactly which function to call, wouldn't it just eliminate the need for typecasting in this kind of situation, and be more efficient at both compile and run time?