Skip to content

Commit 390beb9

Browse files
authored
Merge pull request #67398 from apple/egorzhdan/cxx-pair-mutable
[cxx-interop] Make CxxPair's fields mutable
2 parents 992fc6c + 4ca1eeb commit 390beb9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

stdlib/public/Cxx/CxxPair.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public protocol CxxPair<First, Second> {
1717
associatedtype First
1818
associatedtype Second
1919

20-
var first: First { get }
21-
var second: Second { get }
20+
var first: First { get set }
21+
var second: Second { get set }
2222
}

test/Interop/Cxx/stdlib/use-std-pair.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ StdPairTestSuite.test("PairStructInt.elements") {
3333
expectEqual(pair.second, 11)
3434
}
3535

36+
StdPairTestSuite.test("StdPair as CxxPair") {
37+
func changeFirst(_ p: inout any CxxPair<CInt, CInt>) {
38+
p.first = 123
39+
}
40+
41+
var pair: any CxxPair<CInt, CInt> = getIntPair()
42+
changeFirst(&pair)
43+
expectEqual(pair.first, 123)
44+
}
45+
3646
runAllTests()

0 commit comments

Comments
 (0)