On 02/05/2012 12:20 PM, Era Scarecrow wrote: > I've been working and building a struct called 'AllTypes' which I've > come to the conclusion is already available as a variant. However as I > look at the documentation I don't see any methods/constructors to use > where I can specify where I want the data to be access from. > > The data I will be accessing has dozens of different structures of > records which I keep the formatting and types saved in an array. I see > the problem where although variant can handle what I need, but I don't > see a way to specify a specific memory range/access in order to use it. > > ubyte[] buffer; > > //buffer is loaded at some point with data so length > 0; > buffer.length = 2; > > //0 is the offset from the buffer rather than making a range. > Variant v(buffer, int8, 0); > v = 10; > assert(buffer[0] == 10); > > v = Variant(buffer, int8, 1); > v = 25; > > assert(buffer[0] == 10); > assert(buffer[1] == 25);
I see that it's not exactly what you are looking for, but have you looked at std.conv.emplace()?
Ali
