You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Bugzilla 24890 - spec/arrays.dd should mention comparison and war… (#3930)
* Fix Bugzilla 24890 - spec/arrays.dd should mention comparison and warn about dangling .ptr
Add comparison section.
Introduce .length earlier in the docs.
Define `a == b` and `a is b` for arrays.
Add link to array RelExpression.
Tweak assignment example so comments refer to actual elements.
Make *Array Length* a sub-heading of slicing.
Add relative links for properties.
Document that static array .length is known at compile-time.
Add .ptr section.
Document that .ptr can be dangling so it's not `@safe`.
Mention `TypeInfo.initializer`.
* Remove note about TypeInfo.initializer (not really needed)
* Fix dynamic array .init
Returns an array literal with each element of the literal being the $(D .init) property of the array element type.)
627
651
$(TROW $(D .sizeof), Returns the array length multiplied by
628
652
the number of bytes per array element.)
629
-
$(TROW $(D .length), Returns the number of elements in the array.
630
-
This is a fixed quantity for static arrays. It is of type $(D size_t).)
631
-
$(TROW $(D .ptr), Returns a pointer to the first element of the array.)
653
+
$(TROW $(D .length), $(ARGS Returns the number of elements in the array.
654
+
This is a fixed quantity for static arrays, known at compile-time.
655
+
It is of type $(D size_t)).)
656
+
$(TROW $(RELATIVE_LINK2 ptr-property, `.ptr`), Returns a pointer to the first
657
+
element of the array.)
632
658
$(TROW $(D .dup), Create a dynamic array of the same size and copy the contents of the array into it. The copy will have any immutability or const stripped. If this conversion is invalid the call will not compile.)
633
659
$(TROW $(D .idup), Create a dynamic array of the same size and copy the contents of the array into it. The copy is typed as being immutable. If this conversion is invalid the call will not compile.)
634
660
$(TROW $(D .tupleof), $(ARGS Returns an $(DDSUBLINK spec/template, lvalue-sequences, lvalue sequence) of each element in the array:
@@ -652,15 +678,14 @@ Returns an array literal with each element of the literal being the $(D .init) p
652
678
653
679
$(TABLE_2COLS Dynamic Array Properties,
654
680
$(THEAD Property, Description)
655
-
$(TROW $(D .init), Returns $(D null).)
681
+
$(TROW $(D .init), Returns $(D []).)
656
682
$(TROW $(D .sizeof), $(ARGS Returns the size of the dynamic array reference,
657
683
which is 8 in 32-bit builds and 16 on 64-bit builds.))
658
-
$(TROW $(D .length), Get/set number of elements in the
684
+
$(TROW $(RELATIVE_LINK2 resize, `.length`), Get/set number of elements in the
659
685
array. It is of type $(D size_t).)
660
-
$(TROW $(D .capacity), Returns the length an array can grow to without reallocating.
661
-
See $(RELATIVE_LINK2 capacity-reserve, here) for details.)
662
-
$(TROW $(D .ptr), Returns a pointer to the first element of the array.
663
-
See $(RELATIVE_LINK2 assignment, assignment).)
686
+
$(TROW $(RELATIVE_LINK2 capacity-reserve, `.capacity`), Returns the length an array can grow to without reallocating.)
687
+
$(TROW $(RELATIVE_LINK2 ptr-property, `.ptr`), Returns a pointer to the first
688
+
element of the array.)
664
689
$(TROW $(D .dup), Create a dynamic array of the same size and copy the contents of the array into it. The copy will have any immutability or const stripped. If this conversion is invalid the call will not compile.)
665
690
$(TROW $(D .idup), Create a dynamic array of the same size and copy the contents of the array into it. The copy is typed as being immutable. If this conversion is invalid the call will not compile.)
666
691
)
@@ -693,6 +718,33 @@ assert(b !is a); // b is an independent copy of a
693
718
---------
694
719
)
695
720
721
+
$(H3 $(LNAME2 ptr-property, `.ptr` Property))
722
+
723
+
$(P The `.ptr` property will give a pointer to the first element in a
0 commit comments