From cppreference, one of the std::unique_ptr
constructors is
explicit unique_ptr( pointer p ) noexcept;
So to create a new std::unique_ptr
is to pass a pointer to its constructor.
unique_ptr<int> uptr (new int(3));
Or it is the same as
int *int_ptr = new int(3);
std::unique_ptr<int> uptr (int_ptr);
The different is you don't have to clean up after using it. If you don't use std::unique_ptr
(smart pointer), you will have to delete it like this
delete int_ptr;
when you no longer need it or it will cause a memory leak.