std::unique_ptruniquely controls the object to which it points, and therefore does not use reference counting. Singleton provides the creation of only one object using reference counting.
std::unique_ptr
Will it then std::unique_ptrperform identically singleton?
Singleton provides only one instance per type.
A unique_ptrprovides only one smart pointer for any instance.
unique_ptr
Will std :: unique_ptr execute identically with a singleton?
. , Foo, . , Foo.
std::unique_ptr<Foo> , Foo, Foo ( unique_ptr, ). , Foo, .
std::unique_ptr<Foo>
std::unique_ptr , , .
singleton , unique_ptrs, . , , .
unique_ptrs
, ,
"_ptr .
. :
T* nt = new T; std::unique_ptr<T> up1(nt); std::unique_ptr<T> up2(nt);
, , , . , unique_ptr, , unique_ptr , , api, .
, () , / unique_ptr. .
Correct me if I am wrong, but as far as I remember, singelton is a class that can have only one instance. This is completely different. Then no.