Commit Graph

9 Commits

Author SHA1 Message Date
Egor Zhdan
0ab681514b [cxx-interop] Add CxxMutableRandomAccessCollection protocol
This conforms mutable C++ container types, such as `std::vector`, to `MutableCollection` via a new overlay protocol `CxxMutableRandomAccessCollection`.

rdar://134531554
2024-08-28 12:43:42 +01:00
smonteiro2
15e1749594 Add precondition to prevent access out of bounds
The subscript function from CxxRandomAccessCollection did not perform any bounds-checks.
This means that C++ containers that don't provide the operator[] (or C++ containers used in generic contexts) didn't have bounds-checks.

Fixes rdar://126570011
2024-07-18 15:30:11 +01:00
Egor Zhdan
71cc1bb6f1 [cxx-interop] NFC: move unsafe iterator types to a separate file
Since the unsafe iterator types are now used throughout the overlay, not just by `CxxSequence` and `CxxRandomAccessCollection`, let's move them to a separate file.
2023-02-10 11:57:57 +00:00
Egor Zhdan
7ec8054064 [cxx-interop] Change the hierarchy of CxxSequence protocols
This makes `CxxConvertibleToCollection` the base protocol in the hierarchy. Both `CxxSequence` and `CxxRandomAccessCollection` now inherit from `CxxConvertibleToCollection`.
2023-02-06 22:41:26 +00:00
Egor Zhdan
ed70f30101 [cxx-interop] Make Element a primary associated type of CxxSequence etc 2023-02-02 12:48:17 +00:00
Egor Zhdan
da02016ec5 [cxx-interop] Specify Iterator explicitly for CxxRandomAccessCollection
This helps to avoid ambiguity errors when manually conforming a type to `CxxRandomAccessCollection` protocol.
2022-11-07 17:46:49 -08:00
Egor Zhdan
5359c13a83 [cxx-interop] Add explicit typealiases to CxxRandomAccessCollection
This will help us to auto-generate conformances to `CxxRandomAccessCollection`, since synthesized conformances must have all of their witnesses explicitly provided.
2022-11-02 13:51:34 -07:00
Egor Zhdan
6bb0b8e299 [cxx-interop] Optimize default impls of CxxRandomAccessCollection 2022-10-18 13:48:46 +01:00
Egor Zhdan
bc16131166 [cxx-interop] Add CxxRandomAccessCollection protocol
This helps to bridge C++ random access collections, such as `std::vector` and `std::string`, to Swift by conforming them to `Swift.RandomAccessCollection`
2022-10-14 17:39:37 +01:00