Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does boost::flyweight do reference counting?

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?

like image 316
lurscher Avatar asked Jun 11 '26 00:06

lurscher


1 Answers

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.

like image 125
ildjarn Avatar answered Jun 13 '26 14:06

ildjarn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!