4 ms·
Sharing immutable data between multiple places with no single master owner is a perfectly reasonable thing to do in a program.
by mikeash 13y ago
Sharing immutable data between multiple places with no single master owner is a perfectly reasonable thing to do in a program.
- letzjuc 13y agoI fail to see why you need cycles' support for that.
- mikeash 13y agoYou asked for a situation where the lifetime of a resource can't be directly tied to the lifetime of a single storage location. Cycles are a different matter.
- letzjuc 13y ago>You asked for a situation where the lifetime of a resource can't be directly tied to the lifetime of a single storage location. I don't think I asked for that but correct me if I did (maybe I'm just not understanding your point). Anyways, could you elaborate why shared_ptr, unique_ptr, and weak_ptr don't work in that case?
- mikeash 13y agoOops, wasn't you, but the OP I was responding to initially. shared_ptr works fine for my example. Shared immutable state is a case where reference counting works extremely well, since immutability implies no cycles.