How to obtain Variant underlying type?

anonymouse anany at mouse.com
Sat Jul 9 23:04:20 UTC 2022


On Saturday, 9 July 2022 at 14:46:36 UTC, Adam D Ruppe wrote:
>
> Impossible; Variant's type is only known at runtime, and this 
> would require compile time knowledge.

Hmmm. Okay, thanks. What I really need to know is how many 
dimensions an array has and the total elements per dimension so 
that I can create temporary storage for it later.

      this(T)(T a)
      in(imported!"std.traits".isDynamic!T)
      {
          data = a; // data is of type Variant
          shape = [a.length, {?, ...}]; // what's the best way to 
deterine?
      }

Thanks,
--anonymouse


More information about the Digitalmars-d-learn mailing list