Skip to content

Commit bddedda

Browse files
committed
[cxx-interop] NFC: Clarify copying semantics
1 parent 95f4daf commit bddedda

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

stdlib/public/Cxx/CxxConvertibleToCollection.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ internal func forEachElement<C: CxxConvertibleToCollection>(
4040
extension Array {
4141
/// Creates an array containing the elements of a C++ container.
4242
///
43-
/// This initializer copies each element of the C++ container to a new Swift
44-
/// array.
43+
/// This initializes the array by copying every element of the C++ container.
4544
///
4645
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
47-
/// container.
46+
/// container, assuming that each element is copied in O(1). Note that this
47+
/// might not be true for certain C++ types, e.g. those with a custom copy
48+
/// constructor that performs additional logic.
4849
public init<C: CxxConvertibleToCollection>(_ c: C)
4950
where C.RawIterator.Pointee == Element {
5051

@@ -56,11 +57,12 @@ extension Array {
5657
extension Set {
5758
/// Creates an set containing the elements of a C++ container.
5859
///
59-
/// This initializer copies each element of the C++ container to a new Swift
60-
/// set.
60+
/// This initializes the set by copying every element of the C++ container.
6161
///
6262
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
63-
/// container.
63+
/// container, assuming that each element is copied in O(1). Note that this
64+
/// might not be true for certain C++ types, e.g. those with a custom copy
65+
/// constructor that performs additional logic.
6466
public init<C: CxxConvertibleToCollection>(_ c: C)
6567
where C.RawIterator.Pointee == Element {
6668

stdlib/public/Cxx/CxxSequence.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ extension CxxSequence {
126126
/// Returns an iterator over the elements of this C++ container.
127127
///
128128
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
129-
/// container.
129+
/// container, assuming that each element is copied in O(1). Note that this
130+
/// might not be true for certain C++ types, e.g. those with a custom copy
131+
/// constructor that performs additional logic.
130132
@inlinable
131133
public func makeIterator() -> CxxIterator<Self> {
132134
return CxxIterator(sequence: self)

0 commit comments

Comments
 (0)