CPPCheck 2.11 reports that a value parameter should be const & qualified when the function uses std::move on the argument. This is typically for moving a new object into a container. The object is created for a function parameter and then the function moves it into the container. I don't think that CPPCheck is tackling move semantics well curently.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wasn't aware that noexcept was affecting this. It is interesting and possibly useful that the constructor can be declared noexcept since the argument object would throw during its construction before the construction of the NameContainer which now won't throw.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CPPCheck 2.11 reports that a value parameter should be const & qualified when the function uses std::move on the argument. This is typically for moving a new object into a container. The object is created for a function parameter and then the function moves it into the container. I don't think that CPPCheck is tackling move semantics well curently.
There is no warning with head for
Whats head? In your example m is constructed before the move. Copy assignment would be better.
Please provide a sample that reproduces the issue.
class NameContainer {
public:
explicit NameContainer(std::string /in file name/) noexcept;
private:
std::string inName_;
};
NameContainer::NameContainer(std::string inName) noexcept : inName_(std::move(inName)) {
}
Thanks, ticket is here: https://trac.cppcheck.net/ticket/11995
I wasn't aware that noexcept was affecting this. It is interesting and possibly useful that the constructor can be declared noexcept since the argument object would throw during its construction before the construction of the NameContainer which now won't throw.