I have a block of code where I am using unique_ptr
.
class Abc {
public:
std::string msg;
Abc(std::string m) {
msg = m;
std::cout << "Constructor: " << msg << std::endl;
}
~Abc() {
std::cout << "Destructor: " << msg << std::endl;
}
};
int main() {
auto p = std::make_unique<Abc>(Abc(__func__));
}
But the destructor is called two times. Is there a way I can make it call the destructor only one time?