2 ms·
> Heap allocations should be managed with an RAII class Isn't this what a `unique_ptr` is (a RAII class that manages Heap allocation)? > sink functions" shoul
by Joky 9y ago
> Heap allocations should be managed with an RAII class
Isn't this what a `unique_ptr` is (a RAII class that manages Heap allocation)?
> sink functions" should take an rvalue reference (which semantically means "take ownership of this parameter").
Why not take by value?
- smitherfield 9y ago>Isn't this what a `unique_ptr` is (a RAII class that manages Heap allocation)? See my reply to kllrnohj above: https://news.ycombinator.com/item?id=15872509 https://news.ycombinator.com/item?id=15872509 >Why not [write sink functions that] take by value? That could work in the case where the parameter is a class which is movable but not copyable, but I'd still prefer an rvalue reference in that case because it makes your meaning obvious without having to refer to the class definition or documentation.