Polymake Template Library (PTL): Reference Counting
Polymake Template Library (PTL)  4.2
Reference Counting

Most of the top-level PTL data structures keep their data attached to a smart pointer combined with a reference counter. This technique provides for cheap copy and assignment operations and return of complex objects by value. As long as several objects are not changed, they can safely share a single physical collection of data. A non-const access eventually forces the creation of one's own copy of the data (so called copy-on-write strategy.) Obviously, there's also a drawback of reference counting, since the counter checking produces some overhead. So, one should declare one's objects const whenever one can - this will surely bring a considerable runtime gain.

In general, another danger usually entailed by reference counting is the possibility of creating self-referenced cyclic structures which can never get destroyed. However, this is impossible in the PTL, since we do not use any recursive list structures.