How to obtain Variant underlying type?

anonymouse anany at mouse.com
Sun Jul 10 17:26:58 UTC 2022


On Sunday, 10 July 2022 at 06:26:37 UTC, jfondren wrote:
> ```d
> import std.variant : Variant;
>
> size_t[] shape(Variant v) {
>     import std.variant : VariantException;
>
>     size_t[] s;
>     try {
>         while (true) {
>             Variant elem = v[0];
>             s ~= v.length;
>             v = elem;
>         }
>     } catch (VariantException e) {
>         return s;
>     }
> }
> ```

Thank you very much.



More information about the Digitalmars-d-learn mailing list