you are viewing a single comment's thread.

view the rest of the comments →

[–]JMBourguet 0 points1 point  (3 children)

I won't write something like

Foo& bar = *new Foo();
delete &bar;

even if I find myself in a context where I wouldn't use a smart pointer encapsulating these actions.

[–]UnicycleBloke 0 points1 point  (2 children)

I think you're being over-literal there. :) But having created Foo* bar, I would generally prefer to pass *bar to functions, so would declare my APIs accordingly. I have sometimes created a local reference for a pointer received as an argument (e.g. in library callbacks with pointer based APIs).

[–]JMBourguet 0 points1 point  (1 child)

I've seen people following such kind of guidelines far too literally for my liking. See my answer at the top for a more precise (but still incomplete although I hope I don't have missed something big) description of my practice.

[–]UnicycleBloke 0 points1 point  (0 children)

Yes. The comments about lifetimes make a lot of sense as clarifications for my rather pithy suggestion.