[cxx-interop] Document support for C++ stdlib types#1403
Conversation
Support added as of swiftlang/swift@cb486c6
These have been supported as of: - std::multiset: swiftlang/swift@6366878 - std::multimap: swiftlang/swift@6caaa77
Support for std::span has been documented elsewhere as of swiftlang/swift@19a09f4 CxxSpan was introduced to give std::span a more ergonomic Swift API in swiftlang/swift@e86099c
Conversions to and from Swift Durations were added in swiftlang/swift@53fb653
Support for calling std::function in Swift added in swiftlang/swift@2d0863a Support for constructing std::function in Swift added in swiftlang/swift@7fc815e I changed the example of std::function not being supported to std::tuple, which to my knowledge is not really supported (yet).
Group these a little bit to make it seem less like an append-only list of C++ stdlib types.
Xazax-hun
left a comment
There was a problem hiding this comment.
The change looks good to me, but I almost wonder if we reached a point where we should only mention what is NOT supported because most things (even new containers) should just work out of the box.
I was thinking that too, but I think we should also expand our documentation about what we do support and have examples using each of them |
| Other standard library types, like `std::function` and `std::variant`, are not | ||
| yet supported in Swift. | ||
| - `std::string`, `std::u16string`, `std::u32string`, `std::string_view` | ||
| - Specializations of `std::pair` and `std::optional` |
There was a problem hiding this comment.
Minor: did you group std::pair and std::optional together for a reason?
There was a problem hiding this comment.
Yeah, I did so here e4f57d6 since they're both small type-level combinators for structuring values
| - Specializations of `std::vector`, `std::array`, and `std::span` | ||
| - Specializations of `std::map`, `std::unordered_map` and `std::multimap` | ||
| - Specializations of `std::set`, `std::unordered_set` and `std::multiset` | ||
| - Specializations of `std::shared_ptr` and `std::unique_ptr` |
There was a problem hiding this comment.
Do we want to mention that std::unique_ptr is not fully supported in Windows?
One example is |
This is true, but the existence of an overlay protocol implies we guarantee a stronger level support than what you'd get out of the box + those protocols should also mean we are actively testing the support in our regression tests. For now, I think we should keep it to known good cases until we've thoroughly evaluated how well interop works for non-overlay types + gotten to a point where we can actually enumerate what doesn't work. |
Motivation:
This list has not been kept up to date as we've added more support for C++ interop.
Modifications:
Document which C++ stdlib types we support, especially those that we have tests for, or special compiler handling for.
Result:
The list of supported types.