Hello all.
I'm about to add the network class to the objects that need to send information to the server.
By adding a weak_ptr of the network class thats is a shared_ptr into the base object.
Is the weak pointerer ok for this what I'm lead to believe, is that if the network layer is deleted which it can be at any time when disconnect happens.
that doing this
if( auto tmp = weak1.lock() )
//good to use
else
//has been deleted
will stop any use of the class after its been deleted, but no object will be able to keep the shared_ptr alive which would be bad if a dissconnect occurs.
This is my first use for a weak_ptr.
So will the weak_ptr protect me from a deleted network class. Has to be better then a raw pointer.
I was thinking of passing the network class to functions but there is 17 functions and some functions are deep down in sub systems.
never lead to a clean route.
or any other way to pass network class to things that need them.