Interesting question on StackOverflow – Why does unique_ptr take two template parameters when shared_ptr only takes one?
I haven’t used std::unique_ptr much and wasn’t aware that you could supply a custom deletor.
If you provide the deleter as template argument (as in unique_ptr) it is part of the type and you don’t need to store anything additional in the objects of this type. If deleter is passed as constructor’s argument (as in shared_ptr) you need to store it in the object. This is the cost of additional flexibility, since you can use different deleters for the objects of the same type
Since unique_ptr is lightweight and doesn’t have the overhead of a control block, it uses a template parameter for the deletor. std::shared_ptr takes the other choice since it already has a control block and gains the extra flexibility.
This is the best book by Jo Nesbo that I’ve read. It stands out due to the quality of the back story that he tells, set during World War I. It’s also set early in the timeline of the lead character, Harry Hole, and includes how he met Rakel (who features heaviliy in other stories including The Snowman).
I picked this book in my local book shop, not having read anything by this author before. It took a couple of attempts before I was hooked, but once the main character, Joe Pickett, had travelled to YellowStone Park and begun his investigations, I really enjoyed it. The character breaks the mold for this kind of thriller: he isn’t particularly violent (and admits to being rubbish with a weapon) – that side of things is left to his side-kick, Nate); he doesn’t seem all that sure of himself (unlike 