unique_ptr

The std::unique_ptr is developed in C++11 as a replacement for std::auto_ptr.
Compared with auto_ptr, unique_ptr is a new facility with similar functionality, but with improved security (no fake copy assignments), added features (deleters) and support for arrays. It is a container for raw pointers. It explicitly prevents copying of its contained pointer as would happen with normal assignment, i.e. it allows exactly one owner of the underlying pointer.
So, when using unique_ptr there can only be at most one unique_ptr at any one resource and when that unique_ptr is destroyed, the resource is automatically claimed. Also, since there can only be one unique_ptr to any resource, so any attempt to make a copy of unique_ptr will cause a compile-time error.
```
#include <memory>
#include <iostream>
using std::cout, std::endl;
 
int main()
{
    std::unique_ptr<int> p1(new int);
    *p1 = 10;
    cout<<*p1<<endl;
    auto p11 = std::move(p1);
    cout<<p1.get()<<endl;
    cout<<*p11<<endl;
   
   
    auto p2 = std::make_unique<int[]>(10);
    p2.get()[2] = 20;
    cout<<p2.get()[2]<<endl;
    auto p21 = std::move(p2);
    cout<<p2.get()<<endl;
    cout<<p21.get()[2]<<endl;
    
    return 0;
}

/* Output
10
0
10
20
0
20
*/
```