AutosarC++18_03-A18.9.3ΒΆ
The std::move shall not be used on objects declared const or const&
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
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 [8]: 17.3.1 Do not use std::move on objects declared with const or const& type.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
std_move_const |
Call to std::move with argument declared const/const&. |
None |
False |
Options
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.