警告 C26478
不要对常量变量使用
std::move
。 (es.56)
备注
此警告指示 std::move
的使用与 std::move
的预期使用方式不一致。
由于 const
个对象无法移动,因此对它们调用 std::move
是无效的。 此模式可能会导致意外复制。
代码分析名称:NO_MOVE_OP_ON_CONST
示例
struct node
{
node* next;
int id;
};
void foo(const node& n)
{
const node local = std::move(n); // C26478 reported here
// ...
}
要解决此问题,请移除冗余的 std::move
。
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈