On 08/19/2018 10:23 PM, Jonathan M Davis wrote:
On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via
Digitalmars-d-learn wrote:

Maybe something involving using Variant.coerce to convert the payload to
a single common type? Not sure how I would do that though.

You could always create a wrapper type. Whatever code you're dealing with is
going to need to statically know what type it's using even that's a base
type in a class hierarchy. So, you need to present a type which actually has
the appropriate API even if internally, it can dynamically handle several
types which have that API, and it's not known ahead of time which type that
is.


I guess the parts I'm unclear on are:

1. What mechanism does Variant.coerce!SomeType use to attempt conversion to SomeType?

2. How (if possible) can I provide a way to convert something to type SomeType which Variant.coerce!SomeType will then recognize and use?

Reply via email to