janicicpredrag / gclc

GCLC is a mathematical software tool for producing high-quality mathematical illustrations, for teaching mathematics, and for automated proving of geometry theorems.
http://www.matf.bg.ac.rs/~janicic/gclc/
Other
53 stars 7 forks source link

reference count 'Term' hierarchy with 'std::shared_ptr' #83

Closed Smattr closed 4 months ago

Smattr commented 4 months ago

This avoids the need for manual Dispose calls, removing an opportunity for accidental omissions. By leaning on the standard library, we also get a reference counting implementation optimised for the target platform.

A few things to note about this change:

  1. This is significantly more complex and cross-cutting than the previous std::shared_ptr migrations. Unfortunately there seems to be no easy way to break this into smaller steps. We should put some consideration into whether this is definitely an improvement (and also whether it is correct).
  2. There’s a bit of a foot gun wrt type safety that I’ve detailed in the final commit. I’m open to suggestions to improve/avoid this problem.
  3. Some of the decisions here were a bit subjective. E.g. taking shared_ptrs in Insert to do the duplication when calling into these functions as opposed to specifically duplicating the shared_ptr later down the call chain.