MoveOnly and C++ Interop

I saw some motion recently related to move-only types. Is there any interplay yet between C++ interop and move-only types? I'm still hoping to get a proof-of-concept MLIR-in-Swift-via-C++-interop project off the ground!

2 Likes

Looks like there is some support, but only via import_as_ref,

Is it possible yet to add these annotations via API notes?

1 Like

Sorry for the late reply @George ,

We are planning to provide some support for importing move-only C++ types in Swift 5.9, either behind a flag or enabled by default (when C++ interop is enabled). I will provide more details about this in the next C++ interoperability workgroup sync up, and on the forums here over the next week/two.

2 Likes

You should be also be able to start importing move-only C++ types already on main by using -enable-experimental-move-only Swift frontend flag. We're still testing this feature but we have been able to use a type like unique_ptr successfully from Swift - Support `std::unique_ptr`. by zoecarver · Pull Request #65577 · apple/swift · GitHub.

2 Likes