News for hackers. Stuff that matters.
Re:Under the hood of C++ lambdas and std::function by Too on Monday March 28, 2016 @03:53AM (#11373182)
In c++ if you pass something as reference there is nothing preventing the receiving function from keeping a pointer to that reference even after returning.

Right now the only way to enforce this is by convention: 1. move/unique/shared_ptr=receiver allowed to keep pointer, 2. raw ptr=totally banned, 3. reference=caller must outlive callee and called function is not allowed to keep pointer after returning. The last scenario here is not enforcable by the compiler.

There are no comments on this comment yet.