Main Content
MISRA C++:2023 Rule 28.6.1
Description
Rule Definition
The argument to std::move
shall be a
non-const
lvalue.
Rationale
When arguments to std::move()
are specified as
const
or const&
, the copy constructor is called
instead of the move constructor.
Avoid calling the std::move()
function on const
objects. If you want to perform a move operation, cast the const
object
to a non-const
object, and then move the non-const
object.
Polyspace Implementation
Polyspace® reports a violation of this rule when the std::move()
function is called with an object declared const
or
const&
.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Algorithms library |
Category: Required |
Version History
Introduced in R2024b