fork download
  1. #include <iostream>
  2. #include<memory>
  3. using namespace std;
  4.  
  5. int main() {
  6. constexpr long long sz = 1000000e10;
  7.  
  8. //raw pointer
  9. auto ptr = new(std::nothrow) char[sz];
  10. if(ptr==nullptr)
  11. {
  12. cout<<"ptr nullptr"<<endl;
  13. }
  14.  
  15. //smart pointer
  16. std::unique_ptr<char> sp(new(std::nothrow) char[sz]);
  17.  
  18. if(!sp)
  19. {
  20. cout<<"sp nullptr bool"<<endl;
  21. }
  22.  
  23. if(sp==nullptr)
  24. {
  25. cout<<"sp nullptr =="<<endl;
  26. }
  27. return 0;
  28.  
  29. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
ptr nullptr
sp nullptr bool
sp nullptr ==