Implicit Constructors
Meta
jared771 at gmail.com
Fri Oct 13 14:55:49 UTC 2017
On Friday, 13 October 2017 at 14:28:43 UTC, Adam D. Ruppe wrote:
> On Friday, 13 October 2017 at 14:22:05 UTC, Meta wrote:
>> It'd be nice if it did, because I believe it would enable the
>> following:
>
> I don't think so, since the implicit construction would only
> work one level deep. So you can implicit construct the array,
> but not the individual variants in the array.
You can get very close but I don't think this will work with
inheritance. If that could be fixed then it should be a workable
solution (I think):
class VArray
{
Variant[] va;
this(T...)(T ts) { foreach(t; ts) { va ~= Variant(t); } }
}
void test2(VArray ta...)
{
foreach (v; ta.va)
{
writeln(v.type);
}
}
void main()
{
test2(1, "asdf", false);
}
More information about the Digitalmars-d
mailing list