I was wondering if this code is leak safe:
m_clients.emplace_back(std::unique_ptr<Client>(new Client()));
Logically I see two throw points, new can obviously throw with bad_alloc, and I -believe- the unique_ptr constructor can throw, but I'm not entirely sure about that. I'm not sure if the allocation ends up a no-op with a certain combination of setup like this. As far as I know something like just new Client() can leak, since it would involve a copy operation, but I'm not totally sure.
I can't seem to find any information on the order of operations when you pass a constructor to variadic templates like this. For instance I wasn't sure if it say.. called new and -then- passed the address to emplace_back, and I wasn't sure if emplace_back could throw at that point either. In which case it would never even get to constructing the object.
m_clients is a vector<std::unique_ptr<Client>> for those wondering.
So basically, is it leak safe? Why is/isn't it?