Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<memory>
- using namespace std;
- class Obj {
- int some_unique_data_ptr_;
- public:
- Obj() : some_unique_data_ptr_(0) {}
- Obj(const Obj& o) : some_unique_data_ptr_(o.some_unique_data_ptr_+1) {}
- Obj(Obj&& o) : some_unique_data_ptr_(o.some_unique_data_ptr_) {}
- operator int(){ return some_unique_data_ptr_; }
- };
- int main(){
- unique_ptr<Obj> A = make_unique<Obj>();
- unique_ptr<Obj> B = make_unique<Obj>(*A);
- cout << static_cast<int>(*A) << endl;
- cout << static_cast<int>(*B) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment