Uploaded image for project: 'Swift'
  1. Swift
  2. SR-3087

No way to arbitrarily initialise an Array's storage

    XMLWordPrintable

    Details

      Description

      The standard library does not currently expose a way to allocate an Array's storage and (unsafely) initialise its elements, as we can with UnsafeMutablePointer.

      An example use-case is to implement a concurrent map. See: https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20161024/003769.html

      Even though we expose a UMP from Array, it cannot be used to unsafely initialise the Array elements.

      The workaround at the moment is to allocate a UMP, initialise its elements unsafely, and then copy the contents in to an Array via the Array(Sequence) constructor, which is less than optimal.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                nnnnnnnn Nate Cook
                Reporter:
                kawa Karl
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: