remove const from several unique_ptrs
SonarLint reports:
If you use std::unique_ptr const & for a function parameter type, it
means that the function will not be able to alter the ownership of the
pointed-to object by the unique_ptr:
It cannot acquire ownership of the pointed-to object (this would require
a parameter of type std::unique_ptr)
It cannot transfer the object ownership to someone else (this would
require a std::unique_ptr &).
That means the function can only observe the pointed-to object, and in
this case passing a T* (if the unique_ptr can be null) or a T& (if it
cannot) provides the same features, while also allowing the function to
work with objects that are not handled by a unique_ptr (E.G. objects on
the stack, in a vector, or in another kind of smart pointer), thus making
the function more general-purpose.
Signed-off-by:
Rosen Penev <rosenp@gmail.com>
Loading
Please register or sign in to comment