You can roll your own tagged union instead. The S struct can store long and byte[], S.ptr is a pointer to the data.

    enum Type { Long, Bytes }
    struct S {
        Type type;
        void* ptr;
        union {
            long _long;
            byte[] _bytes;
        }
        this(long l) {
            _long = l;
            type = Type.Long;
            ptr = &_long;
        }
        this(byte[] bytes) {
            _bytes = bytes;
            type = Type.Bytes;
            ptr = &_long;
        }
    }
    
    auto s = S(99);
    assert(s.ptr == &(s._long));
    assert(s.ptr == &(s._bytes));

Pedro Lacerda



2012/2/7 Jesse Phillips <jessekphillips+D@gmail.com>
On Tuesday, 7 February 2012 at 00:39:00 UTC, Era Scarecrow wrote:
Unfortunately I'd need to reference a buffer for the known structured types. Variant seems far more useful for making an interpreted language, than for my purposes.

I've been using Variant with LuaD for some time. Sorry it isn't what you need but hopefully you'll know when it will be useful.