Commit Graph

12 Commits

Author SHA1 Message Date
Egor Zhdan
cf8ac14215 [cxx-interop] Initializing a Swift.Array from CxxConvertibleToCollection should not copy the collection
This makes the `CxxConvertibleToCollection` parameter shared, preventing the unnecessary copy of the C++ value.

rdar://110110376
2023-06-06 15:54:58 +01:00
Egor Zhdan
d5f5d4bd55 [cxx-interop] Make CxxConvertibleToCollection.forEach public
This allows clients to iterate over a C++ container which doesn't provide random access with a `.forEach` call.

rdar://107995558
2023-04-18 14:43:43 +01:00
Egor Zhdan
10d74b11aa [cxx-interop] Make some overlay functions inlinable 2023-04-13 13:49:46 +01:00
Egor Zhdan
ad208223ad [cxx-interop] Avoid extra copy in CxxConvertibleToCollection
This improves the performance of iterating over a C++ container that is automatically conformed to `CxxConvertibleToCollection` protocol by removing the extra copy of the container.

This also tightens the requirements of `CxxConvertibleToCollection` by making `begin()` and `end()` non-mutating.
2023-02-06 16:04:28 +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
b350f2b90f [cxx-interop] NFC: rename initializer parameter 2023-02-02 12:47:08 +00:00
Egor Zhdan
b98f71f2d4 [cxx-interop] Allow initializing SetAlgebra from a C++ container 2023-02-02 12:47:08 +00:00
Egor Zhdan
16d02db7aa [cxx-interop] Add internal function CxxConvertibleToCollection.forEach 2023-02-02 12:47:08 +00:00
Egor Zhdan
e3effcc184 [cxx-interop] Allow initializing RangeReplaceableCollection from a C++ container
This makes `Array.init<C: CxxConvertibleToCollection>(C)` more generic by using `RangeReplaceableCollection` protocol instead of concrete `Array` type.
2023-02-02 12:47:08 +00:00
Egor Zhdan
2ac5ccf7c8 [cxx-interop] NFC: Clarify copying semantics 2023-01-12 00:39:32 +00:00
Egor Zhdan
95f4daf578 [cxx-interop] NFC: Use the term "C++ container" consistently 2023-01-05 16:16:33 +00:00
Egor Zhdan
3e1a6dcea4 [cxx-interop] Add CxxConvertibleToCollection protocol
Since we don't automatically conform C++ non-random-access collections to `Swift.Sequence` anymore for performance reasons, we need an alternative way to access the elements of a C++ sequence from Swift.

This allows explicitly converting a C++ sequence to a Swift Array/Set.
2022-11-24 14:04:21 +00:00