SHARE
TWEET

Untitled

a guest Nov 14th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <memory>
  2. #include <iostream>
  3.  
  4. class CustomData
  5. {
  6.     int someValue;
  7.     // ...
  8. };
  9.  
  10. namespace std
  11. {
  12.     template<>
  13.     struct default_delete<CustomData>
  14.     {
  15.         void operator()(CustomData* ptr)
  16.         {
  17.             cout << "deleted" << endl;
  18.         }
  19.     };
  20. }
  21.  
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26.     {
  27.         auto ptr1 = make_unique<CustomData>();
  28.     }
  29.     {
  30.         auto newData = new CustomData;
  31.         auto ptr2 = unique_ptr<CustomData>(newData);
  32.     }
  33.    
  34.     return 0;
  35. }
RAW Paste Data
Top