NewSocketException():
SocketException NewSocketException(string callstack,Socket* socket)
{
SocketException se;
se.callStack = callstack;
se.message = GetLastWinsockErrorMessage(&se.code);
if (socket != nullptr)
se.socket = new Socket(*socket);
return se;
}
NewSocketException()
should make SocketException
struct for me and return it. C++ calls se.~SocketException()
(it deletes se.socket
) when return se;
is executed. I guess that's because se
goes out of scope but it's returned also so I don't know exactly what is going on over here. When this line is done:
SocketException se = NewSocketException("accept() in AcceptThread()",server);
se
contains correct strings (by stepping into I noticed that strings are also being destroyed by ~basic_string() but they are still there when function returns) and correct (the same) pointer value but objet (se.socket) is still destroyed. Why destructor is being called ? Why my object is gone and strings are still there ?