Why can't we derive struct's?

jmh530 john.michael.hall at gmail.com
Tue Dec 25 15:03:14 UTC 2018

On Tuesday, 25 December 2018 at 04:48:22 UTC, 12345swordy wrote:
> On Monday, 24 December 2018 at 23:54:19 UTC, Rubn wrote:
>> [snip]
> I am specifically talking about implicit conversions via 
> inheritance and why it not an idea tool, as (Which I had said 
> before) you have no control on how it does implicit 
> conversions. I am not talking about explicit conversions here.

Instead of implicit conversions, what about using something like
__traits(compiles, cast(U) T.init)
to check whether T can be explicitly casted to U? Then you could 
just create a canCast function that can detect whether it works 
or not. You'd still have to write a template function to check, 
but it works with anything.


More information about the Digitalmars-d mailing list