-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingc++ interopFeature: Interoperability with C++Feature: Interoperability with C++featureA feature request or implementationA feature request or implementation
Description
Motivation
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 also just think it would make C++ a less annoying language.
Proposed solution
Manage tagged C++ classes with ARC. Leverage code already used for ObjC.
Alternatives considered
- a smart pointer which uses the same functions passed to
SWIFT_SHARED_REFERENCE
std::shared_ptr
(can't manually mutate the ref counts)- manually calling the retain/release functions passed to
SWIFT_SHARED_REFERENCE
Additional information
No response
xavgru12
Metadata
Metadata
Assignees
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingc++ interopFeature: Interoperability with C++Feature: Interoperability with C++featureA feature request or implementationA feature request or implementation