Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Hi Loki, I was just wondering two things and I am interested in what you think about them. First, shouldn't the unique_ptr<char be a unique_ptr<char[]> so that the correct version of delete is called? Second, don't you have to destroy all already constructed elements in the constructors when a T constructor would throw an exception.
Ok, thanks for the hints. Starting with your example, this is of course something I didn't think of as I didn't know that std::lock handles this, I supposed that it acts like a normal mutex::lock which gets double locked. While I can see that a proper ordering would fix the problem in the upper example, would the ordering still matter if we'd assume that the mutexs are both unlocked? I can't come up with a test which would deadlock in that case.