File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1332,10 +1332,18 @@ $(H4 $(LNAME2 cast_pointers, Pointers))
1332
1332
1333
1333
$(H4 $(LNAME2 cast_array, Arrays))
1334
1334
1335
- $(P Casting a dynamic array to another dynamic array is done only if the
1336
- array lengths multiplied by the element sizes match. The cast is done
1337
- as a type paint, with the array length adjusted to match any change in
1338
- element size. If there's not a match, a runtime error is generated.)
1335
+ ---
1336
+ T[] a;
1337
+ ...
1338
+ cast(U[]) a
1339
+ ---
1340
+ $(P Casting a non-literal dynamic array `a` to another dynamic array type `U[]`
1341
+ is allowed only when the result will contain every byte of data that was
1342
+ referenced by `a`.
1343
+ This is enforced with a runtime check that the byte length of `a`'s elements
1344
+ is divisible by `U.sizeof`. If there is a remainder, a runtime error is generated.
1345
+ The cast is done as a type paint, and the resulting array's length is set to
1346
+ `(a.length * T.sizeof) / U.sizeof`.)
1339
1347
1340
1348
$(SPEC_RUNNABLE_EXAMPLE_RUN
1341
1349
---
You can’t perform that action at this time.
0 commit comments