Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4340] UnsafeBufferPointer needs a withMemoryRebound method #46919

Closed
atrick opened this issue Mar 24, 2017 · 1 comment
Closed

[SR-4340] UnsafeBufferPointer needs a withMemoryRebound method #46919

atrick opened this issue Mar 24, 2017 · 1 comment
Labels
feature A feature request or implementation improvement standard library Area: Standard library umbrella

Comments

@atrick
Copy link
Member

atrick commented Mar 24, 2017

Previous ID SR-4340
Radar rdar://problem/31236179
Original Reporter @atrick
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 97500090b48ef769f616d5192ac5f06c

Issue Description:

Currently, rebinding memory requires manually dropping down to `baseAddress` + `count`:

  let count = p.count
  p.baseAddress!.withMemoryRebound(to: Int64.self, capacity: count) {
    bar(UnsafeBufferPointer(start: $0, count: count))
  }

We should obviously add a `withMemoryRebound(capacity🙂` to UnsafeBufferPointer and UnsafeMutableBufferPointer.

While we're at it, UnsafeRawBufferPointer should have a bindMemory API.

@glessard
Copy link
Contributor

glessard commented Dec 7, 2017

Implemented as part of SE-0184a

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants