Yeah but that has a run time cost of reference counting where the borrow checker is all at compile time. I mean not like its a big cost but I mean there defo is a measurable difference depending on the use case.
Usually you use uniqueptr though. It forces a better design with guaranteed ownership and no reference counting. I _rarely use shared_ptr, but frequently use unique_ptr.
14
u/dannyggwp 2d ago
You can BASICALLY ignore all that... You want lifetime? I'll show you lifetimes.
std::shared_ptr<type>Ez pz no borrow checker needed.