News for hackers. Stuff that matters.
Re:Mistakes to avoid with C++ 11 smart pointers by Kristine1975 on Sunday May 15, 2016 @02:59AM (#11699825)
Unless they are modified: const reference. Otherwise you cannot pass a temporary object as in:

  void foo(const std::shared_ptr<int>& p);

  ...

  foo(std::make_shared<int>(23));
This will not compile with

  void foo(std::shared_ptr<int>& p);
since a temporary object cannot be implicitly converted to a non-const reference, only to a const one.

There are no comments on this comment yet.