Quantcast
Channel: How do you implement the Singleton design pattern? - Stack Overflow
Viewing all articles
Browse latest Browse all 25

Answer by uuu777 for How do you implement the Singleton design pattern?

$
0
0

Here is my view on how to do proper singletons (and other non-trivial static objects): https://github.com/alex4747-pub/proper_singleton

Summary:

  1. Use static initialization list to instantiate singletons at the right time: after entering main and before enabling multi-threading
  2. Add minor improvements to make it unit-test friendly.

Viewing all articles
Browse latest Browse all 25

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>