Lightning Talk: Best Practices Every C++ Programmer Needs to Follow - Oz Syed - CppCon 2022

Sdílet
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

Komentáře • 16

  • @N....
    @N.... Před rokem +14

    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.

  • @PUZO37RS
    @PUZO37RS Před rokem

    Nice, thanks. Definitely will watch your talk!

  • @DedmenMiller
    @DedmenMiller Před rokem +27

    "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.

  • @KyleSmithNH
    @KyleSmithNH Před rokem +15

    Can't imagine too many use cases where smart pointers aren't the right answer.

    • @eyesopen6110
      @eyesopen6110 Před 3 měsíci

      ... shared_ptr is overkill.

    • @shipweck6253
      @shipweck6253 Před dnem

      @@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;'

  • @james08172007
    @james08172007 Před rokem +6

    I thought it should be use new/delete if you have to

  • @user-xw5cg7by6t
    @user-xw5cg7by6t Před rokem

    Don’t delay is impossible for me…

  • @__hannibaalbarca__
    @__hannibaalbarca__ Před měsícem

    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.

  • @vladimir0rus
    @vladimir0rus Před 5 měsíci +3

    Is it kindergarten conference? I expected something better and deeper from CppCon.

  • @vicrazio
    @vicrazio Před rokem +4

    all pretty obvious

  • @JReuben111
    @JReuben111 Před rokem

    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