180. Static Memory

Question.11

A singleton uses a static local for lazy initialization:

class Logger {
public:
   static Logger& instance() {
       static Logger log;  // Constructed on first call
       return log;
   }
private:
   Logger() { uart_init(115200); }
};

Is the construction of log thread-safe in C++11?

Need Help? Refer to the Quick Guide below

Select Answer