Skip to content

[cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols #77006

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
Oct 15, 2024

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Oct 14, 2024

This adds a pair of Swift protocols that represents C++ iterator types conforming to std::contiguous_iterator_tag requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as std::vector from Swift, for instance, by providing an overload of withContiguousStorageIfAvailable for contiguous containers.

rdar://137877849

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Oct 14, 2024
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from cbd533d to 49eb805 Compare October 14, 2024 15:10
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from 49eb805 to 046d1ad Compare October 14, 2024 16:45
@@ -916,62 +1147,6 @@ struct InputOutputConstIterator {
}
};

struct MutableRACIterator {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(had to move this elsewhere in the file with no source changes)

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from 046d1ad to 855cfba Compare October 14, 2024 16:46
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from 855cfba to 2439be9 Compare October 14, 2024 17:03
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from 2439be9 to 0755e24 Compare October 15, 2024 11:37
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan enabled auto-merge October 15, 2024 11:37
@egorzhdan egorzhdan disabled auto-merge October 15, 2024 11:38
@egorzhdan
Copy link
Contributor Author

@swift-ci Please Build Toolchain Ubuntu 22.04

@egorzhdan
Copy link
Contributor Author

@swift-ci Please Build Toolchain Amazon Linux 2

@egorzhdan
Copy link
Contributor Author

@swift-ci Please Build Toolchain Debian 12

@egorzhdan
Copy link
Contributor Author

@swift-ci Please Build Toolchain Fedora 39

…ntiguousIterator` protocols

This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-contiguous branch from 0755e24 to 3a200de Compare October 15, 2024 13:31
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci Please Build Toolchain Amazon Linux 2

@egorzhdan egorzhdan enabled auto-merge October 15, 2024 16:57
@egorzhdan egorzhdan merged commit 844d103 into main Oct 15, 2024
3 of 4 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/cxx-contiguous branch October 15, 2024 17:01
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