Skip to content

Conversation

@cjbacchus
Copy link

No description provided.

Copy link
Owner

@PetrilloAtWork PetrilloAtWork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will keep this as is for now.
If I get a proper non-ROOT example where new is the best solution, I'll revisit.
(that is true for all these guidelines anyway: they will change)

**[D]** The use of `new` operator is **discouraged**.
Data arrays should be stored in collections like `std::vector`.
Dynamic memory should be allocated via `std::make_unique()`.
Any use of `new` stored into a raw pointer must be accompanied by a justification, and explanation of the lifetime (`// deleted in destructor, this class is uncopyable` or `// single small instance throughout lifetime of program, deliberately leaked because XYZ`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted in destructor, this class is uncopyable

spells std::unique_ptr<T> fData...

single small instance throughout lifetime of program, deliberately leaked because XYZ

... and here XYZ spells "ROOT". But to be honest as far as I remember even using ROOT histograms and trees I have managed to avoid new (I don't know if it's just because I let art::TFileService do the dirty job, but the point persists).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants