One problem is the delay from the time operator new allocates memory to when it's assigned to a Giggle smart pointer. What would happen if operator new allocated a block of memory using, say, a reference-counting GarbageCollector from Giggle. After operator new returned a pointer to that block of memory, the compiler would call the constructor for it. During that constructor, the garbage collection algorithm was switched to mark-&-sweep. Once the constructor was done, then the pointer to the new object was assigned to a Giggle smart pointer. How would the smart pointer know what type of algorithm to use for the object?
I can imagine solutions. Maybe it's possible for operator new to return something other than a void *, thought I doubt it, & even if it is, I'm not sure that can solve the problem completely.
A second possibility is for operator new & the smart pointer classes to share a map to related the newly allocated block to the GarbageCollector object that was used to create it. I think this would work just fine, though it would carry a run-time cost.14.3
A third possibility would be to require that any run-time choice of garbage collection algorithm be made before any other use of Giggle. I suppose this would work fine, but it would require a pointer to the GarbageCollector object that was in use, & it would need to have a default.
Currently, smart pointers in Giggle rely on global variables to point to GarbageCollector objects. I'd like to remove that. It might solve these problems, maybe make that third possibility work just fine.