Skip to content

[cxx-interop] Add explicit typealiases to CxxRandomAccessCollection #61878

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

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

egorzhdan
Copy link
Contributor

This will help us to auto-generate conformances to CxxRandomAccessCollection, since synthesized conformances must have all of their witnesses explicitly provided.

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Nov 2, 2022
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@@ -31,6 +31,9 @@ extension UnsafeMutablePointer: UnsafeCxxRandomAccessIterator {}
public protocol CxxRandomAccessCollection: CxxSequence, RandomAccessCollection {
override associatedtype RawIterator: UnsafeCxxRandomAccessIterator
override associatedtype Element = RawIterator.Pointee
override associatedtype Index = Int
override associatedtype Indices = DefaultIndices<Self>
override associatedtype SubSequence = Slice<Self>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also create a special kind of Slice for C++ collections which would box the collection to avoid extra copies. I'll do that a bit later.

@hyp
Copy link
Contributor

hyp commented Nov 2, 2022

does this need any testing?

@egorzhdan
Copy link
Contributor Author

This is covered by an existing test: test/Interop/Cxx/stdlib/overlay/custom-collection.swift, but I'll add more tests in the CxxRandomAccessCollection conformance synthesis patch.

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

This will help us to auto-generate conformances to `CxxRandomAccessCollection`, since synthesized conformances must have all of their witnesses explicitly provided.
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-rac-overrides branch from 5bce831 to 5359c13 Compare November 2, 2022 20:51
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit c7095e0 into main Nov 3, 2022
@egorzhdan egorzhdan deleted the egorzhdan/cxx-rac-overrides branch November 3, 2022 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants