Reputation: 26983
I've been reading the documentation of boost::flyweight
but i don't see any mention to deallocation or reference counting policies. Basically a flyweight object should behave like a repository of distinct values, but its not clear what happens when a distinct value is not used anymore.
Is it already supported? can it be enabled with some custom factory?
Upvotes: 3
Views: 1019
Reputation: 62995
As with most things in Flyweight, this behavior is dictated by policy, specifically by the Tracking Policy. The default tracking policy is refcounted
:
Tracking Policy providing flyweight instantiations with reference counting semantics: when all the flyweight objects associated to a given value are destroyed, the corresponding entry is erased from flyweight's internal factory.
Upvotes: 6