However, I feel that managing shared memory/resources (std::shared_ptr) could be problematic; and hard-to-maintain code may emerge in the future.
Depending on the problem you are trying to solve, you can likely just do ref-counting in most cases.
You can "externalize" the reference counting mechanism in zig as well:
fnRefContainer(comptimeT:type)type{returnstruct{inner:T,refs:usize,constSelf=@This();pubfninit(alloc:mem.Allocator,inner:T)!*Self{// If T has init method, call that.// ... }pubfnref(self:*Self)*Self{// ... }pubfnunref(self:*Self)void{// If self.refs == 0 and T has deinit method, call that.}};}
For further actions, you may consider blocking this person and/or reporting abuse
Depending on the problem you are trying to solve, you can likely just do ref-counting in most cases.
You can "externalize" the reference counting mechanism in zig as well: