Lightning Talk: Best Practices Every C++ Programmer Needs to Follow - Oz Syed - CppCon 2022
Vložit
- čas přidán 31. 03. 2023
- cppcon.org/
---
Lightning Talk: Best Practices Every C++ Programmer Needs to Follow - Oz Syed - CppCon 2022
github.com/CppCon/CppCon2022
In this session, learn some of the best practices that every C++ programmer needs to ensure successful completion of a project. Learn tips and tricks to speed up your workflow, prevent errors and improve performance.
---
Oz Syed
__
Videos Filmed & Edited by Bash Films: www.BashFilms.com
CZcams Channel Managed by Digital Medium Ltd events.digital-medium.co.uk
#cppcon #programming #cppprogramming - Věda a technologie
Sometimes it is necessary to use new without delete, such as when initializing a smart pointer with a constructor that the calling code has access to but the smart pointer doesn't (e.g. private constructor and friend class). For this reason I suggest avoiding new and delete entirely, except only using new in this specific situation to directly initialize a smart pointer.
Nice, thanks. Definitely will watch your talk!
"new but no delete", no use smart pointers and std::unique
"Make proper use of destructors" RAII, if you use smart pointers you don't need to worry
"Use smart pointers, if you have to" no, other way around, use smart pointers unless you have a good reason not to.
Can't imagine too many use cases where smart pointers aren't the right answer.
... shared_ptr is overkill.
@@eyesopen6110 true but unique_ptr is literally just an abstraction for what you are already doing with (owning) raw pointers. the only thing called in the destructor is the deleter object which (unless you passed a custom deleter object) is just 'delete m_Ptr;'
I thought it should be use new/delete if you have to
i agree, just use smart pointers
Don’t delay is impossible for me…
I stop use smart pointer, instead we make pointer as in C. We have another code manage to collect all this and making analyze where we must freeing resource.
a garbage collecter?
Is it kindergarten conference? I expected something better and deeper from CppCon.
Me too…
all pretty obvious
If only the compiler would force you to make memory safety guarantees and move semantics were the default
I have recently been looking at a lib to help reduce footguns: CXX
its time for rustc