Skip to content

Commit 70bc1b0

Browse files
authored
Merge pull request #72537 from lorentey/roll-back-most-cxxinterop-changes
2 parents 02301d6 + 621bd47 commit 70bc1b0

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

stdlib/public/Cxx/UnsafeCxxIterators.swift

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
///
1919
/// - SeeAlso: https://en.cppreference.com/w/cpp/named_req/InputIterator
2020
public protocol UnsafeCxxInputIterator: Equatable {
21-
associatedtype Pointee: ~Copyable
21+
associatedtype Pointee
2222

2323
/// Returns the unwrapped result of C++ `operator*()`.
2424
///
@@ -34,23 +34,19 @@ public protocol UnsafeCxxInputIterator: Equatable {
3434
func successor() -> Self
3535
}
3636

37-
extension UnsafePointer: UnsafeCxxInputIterator
38-
where Pointee: ~Copyable {}
37+
extension UnsafePointer: UnsafeCxxInputIterator {}
3938

40-
extension UnsafeMutablePointer: UnsafeCxxInputIterator
41-
where Pointee: ~Copyable {}
39+
extension UnsafeMutablePointer: UnsafeCxxInputIterator {}
4240

4341
extension Optional: UnsafeCxxInputIterator where Wrapped: UnsafeCxxInputIterator {
4442
public typealias Pointee = Wrapped.Pointee
4543

4644
@inlinable
4745
public var pointee: Pointee {
48-
_read {
49-
guard let value = self else {
50-
fatalError("Could not dereference nullptr")
51-
}
52-
yield value.pointee
46+
if let value = self {
47+
return value.pointee
5348
}
49+
fatalError("Could not dereference nullptr")
5450
}
5551

5652
@inlinable
@@ -67,8 +63,7 @@ public protocol UnsafeCxxMutableInputIterator: UnsafeCxxInputIterator {
6763
override var pointee: Pointee { get set }
6864
}
6965

70-
extension UnsafeMutablePointer: UnsafeCxxMutableInputIterator
71-
where Pointee: ~Copyable {}
66+
extension UnsafeMutablePointer: UnsafeCxxMutableInputIterator {}
7267

7368
/// Bridged C++ iterator that allows computing the distance between two of its
7469
/// instances, and advancing an instance by a given number of elements.
@@ -84,14 +79,11 @@ public protocol UnsafeCxxRandomAccessIterator: UnsafeCxxInputIterator {
8479
static func +=(lhs: inout Self, rhs: Distance)
8580
}
8681

87-
extension UnsafePointer: UnsafeCxxRandomAccessIterator
88-
where Pointee: ~Copyable {}
82+
extension UnsafePointer: UnsafeCxxRandomAccessIterator {}
8983

90-
extension UnsafeMutablePointer: UnsafeCxxRandomAccessIterator
91-
where Pointee: ~Copyable {}
84+
extension UnsafeMutablePointer: UnsafeCxxRandomAccessIterator {}
9285

9386
public protocol UnsafeCxxMutableRandomAccessIterator:
9487
UnsafeCxxRandomAccessIterator, UnsafeCxxMutableInputIterator {}
9588

96-
extension UnsafeMutablePointer: UnsafeCxxMutableRandomAccessIterator
97-
where Pointee: ~Copyable {}
89+
extension UnsafeMutablePointer: UnsafeCxxMutableRandomAccessIterator {}

0 commit comments

Comments
 (0)