Tuple opAssign type deduction

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 23 16:31:36 PST 2014


On Wed, 24 Dec 2014 00:16:33 +0000
aldanor via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> alias T = Tuple!(int, "a", double, "b");
> T foo = [1, 2]; // works
> T bar;
> bar = [1, 2]; // doesn't?
> 
> Wonder if there's an obvious reason to this?

you mean "other than the fact that `T foo = [1, 2];` is initalization,
not assigning"? ;-)

you just stepped into two operations that looking almost the same, but
does very different things.

the thing is that Tuple supports assigning only from another Tuple. it
is possible to build `opAssign` templates to support the case you
shown, but it will be cumbersome and will bloat the code.

tl;dr: nobody wrote the proper `opAssign` generator. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141224/d413cfb5/attachment.sig>


More information about the Digitalmars-d mailing list