Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <memory>
- #include <iostream>
- class CustomData
- {
- int someValue;
- // ...
- };
- namespace std
- {
- template<>
- struct default_delete<CustomData>
- {
- void operator()(CustomData* ptr)
- {
- cout << "deleted" << endl;
- }
- };
- }
- using namespace std;
- int main()
- {
- {
- auto ptr1 = make_unique<CustomData>();
- }
- {
- auto newData = new CustomData;
- auto ptr2 = unique_ptr<CustomData>(newData);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment