Answer the question
In order to leave comments, you need to log in
C++11 smart pointers?
There are abstract classes in the code. Naturally, you have to use pointers to work with them; known to me, there are shared_ptr and weak_ptr, where several pointers can point to one object, and unique_ptr, where instead of copying, there is a transfer.
I need such a smart pointer that each pointer is the owner of one object, and when the pointer is copied, the object is copied (as I understand it, the .clone() method cannot be dispensed with here). At the moment I have my own implementation, but it seems to me that I invented the wheel.
Answer the question
In order to leave comments, you need to log in
“a pointer that owns a unique object, and when the pointer is copied, the object is copied ...” - can you use the object itself without any pointers? overload copy constructors and assignment operator and go ahead. what is the difference from what you need?
Firstly, you want something strange, and secondly, look at Qt's QSharedData and QSharedDataPointer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question