Reducing immediate dangling?
summary
Immediate dangling from temporaries is prevented by ref-qualifying member functions using the C++11 feature, not by vague coding hygiene; examples include taking begin from a temporary vector and binding string_view to a short-lived string. A side-effect destructor test demonstrates undefined behavior where an assignment on a temporary leaves a member set to 42. The concrete suggestion is to ref-qualify getters and even make defaults ref-qualify assignment operators so calls on temporaries fail to compile.
AI-written summary · about








