Variable could be declared as const ref
Similar to message: 953 - Variable 'Symbol' (Location) could be declared as const
I would like to see a message for the following situation:
struct X
{
int i;
};
struct Y
{
const X& f();
};
int g( Y y)
{
const X x = y.f();
return x.i + 5;
}
In this case variable x could be declared as const ref.
When the intialization of a const variable is done with an other const variable or a function returning a const reference this message (or maybe two separete messages) could be issued
1
vote
J. van Hoorn
shared this idea