182. Static Memory-ii

Question.5

A singleton pattern 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

Restart quiz!