Dispatching on a variant

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Sep 26 07:21:05 PDT 2009


Justin Johansson wrote:
> I've had a good poke around the forums and couldn't find anything on this so ...
> 
> What's the recommended method for dispatching code off the runtime type of a variant variable
> (Phobos D2 std.variant)?
> 
> Does one use a bunch of
> 
> if ( var.peek!(type1)) { ... }
> else if ( var.peek!(type2)  { ... }
> 
> for all N possible types, or is there a better & faster way with a switch or jump table of sorts?
> 
> Thanks all.
> 
> -- Justin Johansson

I'd planned to implement visitation for Variant, but never got around to it.

Andrei



More information about the Digitalmars-d mailing list