File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -847,7 +847,7 @@ template Tuple(Specs...)
847
847
* source `Tuple` must be implicitly assignable to each
848
848
* respective element of the target `Tuple`.
849
849
*/
850
- void opAssign (R)(auto ref R rhs)
850
+ ref Tuple opAssign (R)(auto ref R rhs)
851
851
if (areCompatibleTuples! (typeof (this ), R, " =" ))
852
852
{
853
853
import std.algorithm.mutation : swap;
@@ -870,6 +870,7 @@ template Tuple(Specs...)
870
870
// Do not swap; opAssign should be called on the fields.
871
871
field[] = rhs.field[];
872
872
}
873
+ return this ;
873
874
}
874
875
875
876
/**
@@ -1802,6 +1803,22 @@ private template ReverseTupleSpecs(T...)
1802
1803
);
1803
1804
}
1804
1805
1806
+ // Issue 8494, parte uno
1807
+ @safe unittest
1808
+ {
1809
+ auto a = tuple(3 , " foo" );
1810
+ assert (__traits(compiles, { a = (a = a); }));
1811
+ }
1812
+ // Ditto
1813
+ @safe unittest
1814
+ {
1815
+ Tuple ! (int []) a, b, c;
1816
+ a = tuple([0 , 1 , 2 ]);
1817
+ c = b = a;
1818
+ assert (a[0 ].length == b[0 ].length && b[0 ].length == c[0 ].length);
1819
+ assert (a[0 ].ptr == b[0 ].ptr && b[0 ].ptr == c[0 ].ptr);
1820
+ }
1821
+
1805
1822
/**
1806
1823
Constructs a $(LREF Tuple) object instantiated and initialized according to
1807
1824
the given arguments.
You can’t perform that action at this time.
0 commit comments