fork download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. int main()
  5. {
  6. std::unique_ptr<int> pi = std::make_unique<int>();
  7. std::unique_ptr<int> pj = pi;
  8.  
  9. *pi = 23;
  10.  
  11. std::cout << *pi << '\n';
  12. }
  13.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:23: error: call to deleted constructor of 'std::unique_ptr<int>'
        std::unique_ptr<int> pj = pi;
                             ^    ~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/unique_ptr.h:394:7: note: 'unique_ptr' has been explicitly marked deleted here
      unique_ptr(const unique_ptr&) = delete;
      ^
1 error generated.
stdout
Standard output is empty