--- description: "Learn more about: Warning C26478: Don't use std::move on constant variables. (es.56)" title: Warning C26478 ms.date: 07/15/2019 f1_keywords: ["C26478", "NO_MOVE_OP_ON_CONST"] helpviewer_keywords: ["C26478"] --- # Warning C26478 > Don't use `std::move` on constant variables. (es.56) ## Remarks This warning is to indicate that the use of `std::move` not consistent with how `std::move` is intended to be used. When called on a `const` object, `std::move` returns a copy of the object, which is likely not the developer's intent. Code analysis name: `NO_MOVE_OP_ON_CONST` ## Example 1 ```cpp struct node { node* next; int id; }; void foo(const node& n) { const node local = std::move(n); // C26478 reported here // ... } ``` An assignment operator or using the passed in parameter will prevent this warning from being issued and will adequately serve the developer's use case. ## Example 2 ```cpp struct s; template void bar(T t){}; void foo() { const s s1; bar(std::move(s1)); // C26478 reported here } ``` ## See also [ES.56 - Write std::move() only when you need to explicitly move an object to another scope](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es56-write-stdmove-only-when-you-need-to-explicitly-move-an-object-to-another-scope)