From CppNow 2013

Timothee Cour thelastmammoth at gmail.com
Wed Jun 12 10:47:59 PDT 2013


On Wed, Jun 12, 2013 at 5:38 AM, Andrei Alexandrescu <
SeeWebsiteForEmail at erdani.org> wrote:

> On 6/12/13 5:38 AM, Timothee Cour wrote:
>
>> However I've implemented something that works exactly as required:
>>
>> https://github.com/**timotheecour/dtools/blob/**
>> master/dtools/util/variant_**nested.d<https://github.com/timotheecour/dtools/blob/master/dtools/util/variant_nested.d>
>>
>>          auto
>> d=variantTupleNamed("a",1,"b",**"foo","c",variantTuple(1,2.2,"**three"));
>>
>
> Do calls to variantTupleNamed nest within one another? This seems
> interesting. We should integrate this with json I/O as well.
>
> Andrei
>

Yes, the base type Variant2 nests recursively.

I've added this to the unittest:

                Variant2 a1=0;
a1=variantTuple(1,"a");
a1[0]=variantTuple("foo",1.1);
auto a2=variantTuple(3,[1]);
a1[1]=a2;
a1~="foo2";
assert(a1.text==`[[foo, 1.1], [3, [1]], foo2]`);

(variantTupleNamed is just a way to construct a named tuple, but works as
variantTuple)

Further, see my comment "read-modify-write works": I would think this could
be applied to std.variant.Variant too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130612/05b7d08c/attachment.html>


More information about the Digitalmars-d mailing list