AutosarC++18_10-M9.3.1¶
const member functions shall not return non-const pointers or references to class-data
Required inputs: IR
Example
class C
{
private:
std::string m_member;
public:
const std::string& member()
{
return m_member;
}
void member(const std::string& new_value)
{
assert(new_value.size() > 0);
m_member = new_value;
}
};
See Also
Rule Miscellaneous-NoPublicDataMembersNote
For legal reasons, this rule’s description is not part of the public documentation.