mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
3a200dee has a logic bug where we tried to conform C++ iterator types to `UnsafeCxxContiguousIterator` protocol based on their nested type called `iterator_category`. The C++20 standard says we should rely on `iterator_concept` instead.
https://en.cppreference.com/w/cpp/iterator/iterator_tags#Iterator_concept
Despite what the name suggests, we are not actually using C++ concepts in this change.
rdar://137877849
36 lines
1.8 KiB
Swift
36 lines
1.8 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomIterator -source-filename=x -I %S/Inputs -cxx-interoperability-mode=swift-6 -Xcc -std=c++20 | %FileCheck %s
|
|
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomIterator -source-filename=x -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++20 | %FileCheck %s
|
|
|
|
// Ubuntu 20.04 ships with an old version of libstdc++, which does not provide
|
|
// std::contiguous_iterator_tag from C++20.
|
|
// UNSUPPORTED: LinuxDistribution=ubuntu-20.04
|
|
// UNSUPPORTED: LinuxDistribution=amzn-2
|
|
|
|
// CHECK: struct ConstContiguousIterator : UnsafeCxxContiguousIterator, UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
|
|
// CHECK: func successor() -> ConstContiguousIterator
|
|
// CHECK: var pointee: Int32
|
|
// CHECK: typealias Pointee = Int32
|
|
// CHECK: typealias Distance = Int32
|
|
// CHECK: }
|
|
|
|
// CHECK: struct HasCustomContiguousIteratorTag : UnsafeCxxContiguousIterator, UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
|
|
// CHECK: func successor() -> HasCustomContiguousIteratorTag
|
|
// CHECK: var pointee: Int32
|
|
// CHECK: typealias Pointee = Int32
|
|
// CHECK: typealias Distance = Int32
|
|
// CHECK: }
|
|
|
|
// CHECK: struct MutableContiguousIterator : UnsafeCxxMutableContiguousIterator, UnsafeCxxMutableRandomAccessIterator, UnsafeCxxMutableInputIterator {
|
|
// CHECK: func successor() -> MutableContiguousIterator
|
|
// CHECK: var pointee: Int32
|
|
// CHECK: typealias Pointee = Int32
|
|
// CHECK: typealias Distance = Int32
|
|
// CHECK: }
|
|
|
|
// CHECK: struct HasNoContiguousIteratorConcept : UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
|
|
// CHECK: func successor() -> HasNoContiguousIteratorConcept
|
|
// CHECK: var pointee: Int32
|
|
// CHECK: typealias Pointee = Int32
|
|
// CHECK: typealias Distance = Int32
|
|
// CHECK: }
|