mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Iterating over a `CxxSequence` that is not a `CxxRandomAccessCollection` triggers a copy of the C++ collection. Let's disable the automatic conformances until we find a more efficient solution. This means that for now developers won't be able to iterate over a `std::set` or `std::list` with a Swift for-in loop. I will submit a separate patch with an alternative solution for such types. C++ random access collections, such as `std::vector` or `std::string`, are not affected.
20 lines
1.0 KiB
Swift
20 lines
1.0 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomSequence -source-filename=x -I %S/Inputs -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s
|
|
|
|
// CHECK: struct SimpleArrayWrapper : CxxRandomAccessCollection {
|
|
// CHECK: typealias Element = UnsafePointer<Int32>.Pointee
|
|
// CHECK: typealias Iterator = CxxIterator<SimpleArrayWrapper>
|
|
// CHECK: typealias RawIterator = UnsafePointer<Int32>
|
|
// CHECK: }
|
|
|
|
// CHECK: struct SimpleCollectionNoSubscript : CxxRandomAccessCollection {
|
|
// CHECK: typealias Element = ConstRACIterator.Pointee
|
|
// CHECK: typealias Iterator = CxxIterator<SimpleCollectionNoSubscript>
|
|
// CHECK: typealias RawIterator = SimpleCollectionNoSubscript.iterator
|
|
// CHECK: }
|
|
|
|
// CHECK: struct SimpleCollectionReadOnly : CxxRandomAccessCollection {
|
|
// CHECK: typealias Element = ConstRACIteratorRefPlusEq.Pointee
|
|
// CHECK: typealias Iterator = CxxIterator<SimpleCollectionReadOnly>
|
|
// CHECK: typealias RawIterator = SimpleCollectionReadOnly.iterator
|
|
// CHECK: }
|