Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge rules R.12 and R.13; explain about RAII factories. #1610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 22, 2020

  1. Merge rules R.12 and R.13; explain about RAII factories.

    R.12 and R.13 were both written for a C-style world where the idea was
    to get raw resource pointers and then quickly "give" them to RAII types.
    The modern C++ approach is actually to use RAII types exclusively,
    and never handle raw resource pointers even for an instant. R.13 was
    kind of getting there, in that it knew `make_shared` existed; but we
    can strengthen the rule by just saying "Please, use `make_shared`."
    
    "Raw pointers are like raw meat: don't touch them with your hands."
    
    Also update for C++17: it's no longer true that `shared_ptr<T>(new T())`
    can ever cause a leak due to interleaved evaluations.
    But it's still a nasty habit. Use `make_shared`.
    Quuxplusone committed Apr 22, 2020
    Configuration menu
    Copy the full SHA
    8e106a4 View commit details
    Browse the repository at this point in the history