singleton pattern and std::unique_ptr

c++, singleton, unique-ptr

Solution

A singleton ensures only one instance of a type.

A `unique_ptr` ensures only one smart pointer to any instance.

Problem

`std::unique_ptr` uniquely controls the object it points to and, hence, does not utilize reference counting. A singleton ensures only one object may be created utilizing reference counting. Would then `std::unique_ptr` perform identically to a singleton?

Original source