ReferenceCountedObject inc and dec


Just curious: what’s the rationale for ReferenceCountedObject::incReferenceCount() and decReferenceCount() not being const mutable?


Well, you could probably argue that one either way… I’ve no strong preference for them being non-const, except that it would feel a bit strange to me to have const methods that very obviously change the object, and may even delete it.


Hmm… I probably spend too long in GC languages, as I instinctively see a value and its references as being decoupled, the reference count being essentially metadata. The deletion case is an interesting point, as in a GC language collection is not (typically[1]) a property of a value, whereas in C++ it absolutely is.

Fair enough.

[1] Ephemeron tables and such aside.