跳转至

base/include/base/singleton/simple_singleton.hpp

Simple thread-safe singleton using Meyer's singleton pattern. More...

Namespaces

Name
cf

Classes

Name
class cf::SimpleSingleton
Simple thread-safe singleton using Meyer's singleton pattern.

Detailed Description

Simple thread-safe singleton using Meyer's singleton pattern.

Author: N/A

Version: N/A

Since: N/A

Date: N/A

Provides a minimal singleton implementation that leverages C++11 guarantees for thread-safe static local variable initialization.

Source code

#pragma once

namespace cf {

template <typename SingleTargetClass> class SimpleSingleton {
  public:
    static SingleTargetClass& instance() {
        static SingleTargetClass target;
        return target;
    }

  private:
    SimpleSingleton(const SimpleSingleton&) = delete;
    SimpleSingleton& operator=(const SimpleSingleton&) = delete;
    SimpleSingleton(SimpleSingleton&&) = delete;
    SimpleSingleton& operator=(SimpleSingleton&&) = delete;
};

} // namespace cf

Updated on 2026-03-09 at 10:14:01 +0000