You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<string>classA
{
public:A(std::string s)
: s_(std::move(s))
{}
private:
std::string s_;
};
externvoidf1(std::string s) {
A a{s}; // performance-unnecessary-value-param
}
externvoidf3(std::string s) {
if (!s.empty()) // performance-unnecessary-value-param
{
A a{s}; // no warning
}
}
<source>:14:6: warning: parameter 's' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] A a{s}; // performance-unnecessary-value-param ^ std::move( )<source>:17:28: warning: the parameter 's' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]extern void f3(std::string s) { ^ const &