Skip to content

[SR-3087] No way to arbitrarily initialise an Array's storage #45677

@karwa

Description

@karwa
Previous ID SR-3087
Radar rdar://problem/21880692
Original Reporter @karwa
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, LanguageFeatureRequest
Assignee @natecook1000
Priority Medium

md5: 78d2891e46bb0f408db15202b1a1b736

relates to:

  • SR-3631 Introduce ContiguouslyStored protocol and kill ArraySlice type

Issue 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.

Metadata

Metadata

Assignees

Labels

featureA feature request or implementationimprovementstandard libraryArea: Standard library umbrellaswift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implemented

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions