Running cppcheck cppcheck --enable=style test.cpp on the following code snippet will result in an error .
using IntPtr = int *;int* foo(IntPtr bar)
{
return bar = 0;
}
test.cpp:3:17: style: Parameter 'bar' can be declared as pointer to const [constParameterPointer]
The problem is that since the type is defined through using (the same behaviour would be observed if I was using typedef), it is not possible to add const here, since it will result in the underlying type int *const rather than const int*.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Running cppcheck
cppcheck --enable=style test.cppon the following code snippet will result in an error .test.cpp:3:17: style: Parameter 'bar' can be declared as pointer to const [constParameterPointer]The problem is that since the type is defined through
using(the same behaviour would be observed if I was usingtypedef), it is not possible to addconsthere, since it will result in the underlying typeint *constrather thanconst int*.