Rule A18-9-3 (required, implementation, automated)
The std::move shall not be used on objects declared const or const&.
Rationale
If an object is declared const or const&, then it will actually never be moved using the std::move.
Example
// $Id: A18-9-3.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <utility>
class A
{
// Implementation
};
void F1()
{
const A a1{};
A a2 = a1;
// Compliant - copy constructor is called
A a3 = std::move(a1); // Non-compliant - copy constructor is called
// implicitly instead of move constructor
}
See also
HIC++ v4.0 [9]: 17.3.1 Do not use std::move on objects declared with const or const& type.