Commit Graph

9 Commits

Author SHA1 Message Date
Crazy凡
b4531a6ae8 [cxx-interop]: Refactor CxxDictionary protocols to use generics instead of Self.
- Add support for merging `std::map` and `std::unordered_map` with each other seamlessly.
- Add support for typed throws
2025-04-02 09:14:06 +08:00
Egor Zhdan
67da2026ea [cxx-interop] NFC: Fix a warning
This fixes a build warning:
```
swift/stdlib/public/Cxx/CxxDictionary.swift:168:9: warning: variable 'iter' was never mutated; consider changing to 'let' constant
```
2024-12-23 16:26:36 +00:00
Crazy凡
c6b10dffd7 "Enhance CxxDictionary with removeValue(forKey:), subscript(key:default:), mergemerging and init(grouping:by:)" 2024-11-28 13:11:31 +08:00
Egor Zhdan
535a9412df [cxx-interop] Conform std::map to ExpressibleByDictionaryLiteral
This adds an automatic conformance for `std::map` and `std::unordered_map` to Swift's `ExpressibleByDictionaryLiteral` protocol.

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

rdar://137126474
2024-10-03 13:33:40 +01:00
Egor Zhdan
9fe13ece49 [cxx-interop] Allow initializing std::map from Swift Dictionary
This adds initializers for `std::map` and `std::unordered_map` that take a Swift dictionary as a single parameter.

rdar://133691563
2024-08-14 13:32:30 +01:00
mohanadkandil
d58943a508 Add filter method for ordered and unordered map (#67501)
Co-authored-by: mkandil <mkandil@synapse-analytics.io>
2023-10-05 19:13:34 +01:00
Egor Zhdan
6caaa77efc [cxx-interop] Allow mutating std::map from Swift
This adds a setter to the `CxxDictionary` subscript which makes it possible to mutate `std::map` and `std::unordered_map` from Swift.

rdar://105399019
2023-08-02 16:44:30 +01:00
Egor Zhdan
7ca1b5c5eb [cxx-interop] NFC: Add doc comments for overlay protocols 2023-07-12 19:10:23 +01:00
Egor Zhdan
919eea7045 [cxx-interop] Add CxxDictionary protocol for std::map ergonomics
This adds a protocol to the C++ standard library overlay which will improve the ergonomics of `std::map` and `std::unordered_map` when used from Swift code.

As of now, `CxxDictionary` adds a subscript with an optional return type that mimics the subscript of `Swift.Dictionary`.

Similar to https://github.com/apple/swift/pull/63244.
2023-02-09 14:31:06 +00:00