The confusion is because an important word is omitted from the common advice:
Don’t use raw pointers, use smart pointers instead. (Again, this is bad advice.)
Better advice is:
Don’t use owning raw pointers, use smart pointers instead.
Raw pointers are still valuable in at least one specific circumstance, namely, optionally pointing to (but not owning) an object. A good example of this is the
UndoManager* parameter to the
AudioProcessorValueTreeState constructor. If you want to use an undomanager, pass a non-null pointer to an UndoManager which is owned elsewhere. If you don’t need an undomanager, pass
That being said, raw pointers are still a bit yucky from a type-checking perspective, as they might point to a single element or the beginning of an array of elements, and there’s no way to distinguish between the two cases from the type of the pointer. If you need to optionally point to an array, something like
std::span is probably a better choice.