I used to like that and it is a great way to have a thread safe singleton but it is horrible when doing unit testing. Nowadays I use a unique_ptr protected with a mutex, sure a bit more overhead but at least I can fully destroy the singleton between unit tests. Just my 2c.
I used to like that and it is a great way to have a thread safe singleton but it is horrible when doing unit testing. Nowadays I use a unique_ptr protected with a mutex, sure a bit more overhead but at least I can fully destroy the singleton between unit tests. Just my 2c.