c++ – How am I “supposed” to hold a pointer to an object I don’t own?

For instance, let’s do this in the context of a dynamic programming solver where each partial solution has a link back to the problem it solves. I might do that like so:

class Problem { /* ... */ };

class PartialSolution
  Problem * problem;

  // ...

This is fine and produces working code — including a default copy constructor and copy-assignment operator that work correctly — but then when I turn on various kinds of warnings things get upset that I’m holding a raw pointer — they assume that I must own the thing I’m pointing at and that I’m not cleaning it up.

So I take it I’m supposed to use some kind of smart pointer? But what are my options here? std::unique_pointer is definitely incorrect, since I don’t own the object. std::shared_pointer would at least work correctly, but it causes me to do unnecessary reference tracking. There’s also std::weak_ptr, but that’s even worse in terms of unnecessary cost because I have to convert it to a temporary std::shared_ptr each time I want to use it.

There’s also std::reference_wrapper in <functional>. This seems like it may actually do to right thing here, although I don’t enough about it to be confident about this and given that it’s in <functional> and not <memory> I feel like this may not be the intent.

Or should I just hold a raw pointer and do something to disable the warnings? (And, if so, what?)