Quick Question about SharedResoucePointer

As the title says.

Is it better to pass a SharedResourcePointer& into any object that needs to use it, or is it fine to just create a member variable of SharedResoucePointer for every object that uses it (Since it will only allow for one SRP of type T).


The whole point of SharedResourcePointer is that you don’t need to pass stuff around. Every instance of a class that has a SharedResourcePointer as a member will be able to use the same underlying object.

If you need other classes to access that object, you should pass the underlying object, not the pointer.

1 Like