Part of my codebase is C++ called from Swift and I've gotta do some refcounting myself.
Wouldn't it be great if C++ objects could be ARC'd like Swift and ObjC objects? Something like:
[[arc]] class MyCoolThing {
...
};
I wouldn't have to use smart pointers to manage the lifetime of MyCoolThing on the C++ side. Currently, I can't manage classes exposed to Swift using std::shared_ptr (right?) so I'd have to create my own smart pointer, or find some other intrusive reference counted smart pointer or just manually retain/release.
I think mixing ARC in with all the existing facilities for memory management in C++ would further complicate the situation (there are already so many ways to manage lifetime in C++). If you really want this you can maybe use ObjC++.
How are you managing memory today? If you are using a smart pointer (including shared_ptr), it should come into Swift and be managed automatically. If you are using some intrusive reference counting, you can use Foreign Reference Types to import your C++ type as a Swift class with automatic reference counting.
Right now I use SWIFT_SHARED_REFERENCE and I derive from an IntrusiveRefCounted just like the page you linked says. But it's not the most ergonomic solution if you're sharing ownership with other C++ objects.
I could embed a shared_ptr in some wrapper class and expose that to swift, but then I'd have to write wrapper functions.