News for hackers. Stuff that matters.
Re:Embracing Modern C++ Safely, Book Review by arinlen on Monday May 30, 2022 @02:34PM (#31562085)
> There are too many APIs that still want raw pointers.

Irrelevant. C++'s smart pointers deal with ownership and life cycle management. You can still pass raw pointers to objects managed by a smart pointers.

The only exception is when you're dealing with a framework which already handles life cycle management, such as Qt. Nevertheless, even Qt offers its own smart pointers suite.

Re:Embracing Modern C++ Safely, Book Review by UncleMeat on Monday May 30, 2022 @05:50PM (#31564000)
> You can still pass raw pointers to objects managed by a smart pointers.

Not if the API is taking ownership and you want your program to be correct. This happens far more often than dealing with something like Qt.

Re:Embracing Modern C++ Safely, Book Review by rtpg on Monday May 30, 2022 @10:25PM (#31565545)
If the API takes ownership, can't you just release the smart pointer, effectively forgetting about it and letting the new owner deal with it? Maybe I'm missing somethign.
Re:Embracing Modern C++ Safely, Book Review by UncleMeat on Tuesday May 31, 2022 @09:52AM (#31569480)
That means it is no longer managed by a smart pointer and you need to understand the nature of the API. I understood the above comment to mean that you can just solve problems by calling "get" and moving on with your life.