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-3590] Implicitly convert &Tuple to UnsafePointer<Tuple.Element> #46175

Closed
atrick opened this issue Jan 10, 2017 · 2 comments
Closed

[SR-3590] Implicitly convert &Tuple to UnsafePointer<Tuple.Element> #46175

atrick opened this issue Jan 10, 2017 · 2 comments
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@atrick
Copy link
Member

atrick commented Jan 10, 2017

Previous ID SR-3590
Radar rdar://problem/31236224
Original Reporter @atrick
Type New Feature
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 324b77b6bdc9f425f17f3e1bfc47b11b

duplicates:

  • SR-11147 Add withUnsafeBufferPointer<T: HomogeneousAggregate, Result>

relates to:

  • SR-4929 Support non-inout homogeneous tuple argument conversion to UnsafePointer

Issue Description:

For convenience add implicit casting from a tuple address to an unsafe pointer to its elements.

This is a natural thing to do and should not require dropping down to a raw pointer and rebinding memory.
See SR-2471.

Example use case:

import Foundation

var bytes: (CChar, CChar, CChar, CChar) = (0x61, 0x62, 0x63, 0)
let name: String = withUnsafePointer(to: &bytes) {
  (ptr: UnsafePointer<CChar>) -> String in
  return String(utf8String: ptr)!
}
@belkadan
Copy link
Contributor

As much as I think this is a good feature I think it technically needs to go through swift-evolution. (Note that this only applies to homogeneous tuples.)

@atrick
Copy link
Member Author

atrick commented Jul 16, 2019

This is a better proposal to fix the same problem:

SR-11147: Add withUnsafeBufferPointer(to: variable) where variable is any homogenous aggregate

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal labels May 18, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

3 participants