Is there any advantage to using a naked pointer rather than a weak_ptr?

Viewed 2629

Question: Are there any compelling reasons to use naked pointers for non-owning resources or should we be using weak_ptr?

CPP.reference states

std::weak_ptr models temporary ownership: when an object needs to be accessed only if it exists, and it may be deleted at any time by someone else

But then, in the accepted answer for Which kind of pointer do I use when? we have the statement:

Use dumb pointers (raw pointers) or references for non-owning references to resources and when you know that the resource will outlive the referencing object / scope. Prefer references and use raw pointers when you need either nullability or resettability.... If you want a non-owning reference to a resource, but you don't know if the resource will outlive the object that references it, pack the resource in a shared_ptr and use a weak_ptr.

This answer is followed by a lot of back-and-forth about the use of naked pointers, with no real resolution. I can't see any reason for using dumb pointers. Am I missing something?

2 Answers
Related