File tree Expand file tree Collapse file tree 1 file changed +6
-28
lines changed Expand file tree Collapse file tree 1 file changed +6
-28
lines changed Original file line number Diff line number Diff line change @@ -1716,37 +1716,15 @@ $(GNAME ArrayMemberInitialization):
1716
1716
---
1717
1717
1718
1718
$(P By default, an array literal is typed as a dynamic array, but the element
1719
- count is known at compile time. So all array literals can be
1720
- implicitly converted to static array types. Slicing a dynamic array with
1721
- statically known bounds also allows conversion to a static array.)
1719
+ count is known at compile time. So an array literal can be
1720
+ implicitly converted to a static array of the same length.)
1722
1721
1723
- $(SPEC_RUNNABLE_EXAMPLE_RUN
1724
1722
-------------
1725
- void foo(long[2] a)
1726
- {
1727
- assert(a == [2, 3]);
1728
- }
1729
- void bar(ref long[2] a)
1730
- {
1731
- assert(a == [2, 3]);
1732
- a = [4, 5];
1733
- assert(a == [4, 5]);
1734
- }
1735
-
1736
- void main()
1737
- {
1738
- long[] arr = [1, 2, 3];
1739
-
1740
- foo(arr[1 .. 3]);
1741
- assert(arr == [1, 2, 3]);
1742
-
1743
- bar(arr[1 .. 3]);
1744
- assert(arr == [1, 4, 5]);
1745
-
1746
- //foo(arr[0 .. 3]); // cannot match length
1747
- }
1723
+ int[2] sa = [1, 2];
1748
1724
-------------
1749
- )
1725
+
1726
+ $(NOTE Slicing a dynamic array with statically known bounds also
1727
+ $(RELATIVE_LINK2 slice_to_static_array, allows conversion) to a static array.)
1750
1728
1751
1729
$(P If any $(I ArrayMemberInitialization) is a
1752
1730
$(DDSUBLINK spec/template, TemplateParameterSequence, ValueSeq),
You can’t perform that action at this time.
0 commit comments