Commit Graph

8 Commits

Author SHA1 Message Date
Crazy凡
aeaa8ecadd [cxx-interop] Allow removing elements from std::set. 2024-11-13 23:16:45 +08:00
Egor Zhdan
f37f42fc7e [cxx-interop] Conform std::set to ExpressibleByArrayLiteral
Swift's own `Set` conforms to `ExpressibleByArrayLiteral`. This change conforms instantiations of C++ `std::set` to `ExpressibleByArrayLiteral` as well.

This makes it possible to pass an array literal as an argument to a function that takes a `std::set` as parameter.

rdar://137126325
2024-10-02 19:27:51 +01:00
Egor Zhdan
7ca1b5c5eb [cxx-interop] NFC: Add doc comments for overlay protocols 2023-07-12 19:10:23 +01:00
Egor Zhdan
b79b65c056 [cxx-interop] Allow inserting elements into std::set from Swift
`std::set::insert` isn't exposed into Swift, because it returns an instance of an unsafe type.

This change adds a Swift overload of `insert` for `std::set` and `std::unordered_set` that has the return type identical to `Swift.Set.insert`: a tuple of `(inserted: Bool, memberAfterInsert: Element)`.

rdar://111036912
2023-06-20 16:56:54 +01:00
Egor Zhdan
042aff2a76 [cxx-interop] Optimize CxxSet initialization from a Swift Sequence
rdar://107909624
2023-06-13 18:04:20 +01:00
Egor Zhdan
dd7e1775fc [cxx-interop] Add std::set initializer that takes a Swift Sequence
rdar://107909624
2023-06-13 14:51:28 +01:00
Egor Zhdan
10d74b11aa [cxx-interop] Make some overlay functions inlinable 2023-04-13 13:49:46 +01:00
Egor Zhdan
6366878308 [cxx-interop] Add CxxSet protocol for std::set ergonomics
This adds a protocol to the C++ standard library overlay which will improve the ergonomics of `std::set`, `std::unordered_set` and `std::multiset` when used from Swift code.

As of now, `CxxSet` adds a `contains` function to C++ sets.

C++ stdlib set types are automatically conformed to `CxxSet`: `std::set`, `unordered_set`, `std::multiset`. Custom user types are not conformed to `CxxSet` automatically: while a custom type might have an interface similar to `std::set`, the semantics might differ, and adding a conformance would cause confusion.
2023-01-26 19:35:30 +00:00