readability-qualified-auto suggests const auto* when initializing an auto variable with a std::array iterator value that happens to be implemented as a raw pointer.
The suggested change is not portable, as the standard only requires that a contiguous_iterator be returned, which does not necessarily have to be a raw pointer.
Example:
#include <array>
int main()
{
std::array<int, 3> array = {{0, 1, 2}};
auto iter = array.cbegin();
return *iter;
}
Clang-Tidy output:
[<source>:6:5: warning: 'auto iter' can be declared as 'const auto *iter' [readability-qualified-auto]]
readability-qualified-auto
suggestsconst auto*
when initializing anauto
variable with astd::array
iterator value that happens to be implemented as a raw pointer.The suggested change is not portable, as the standard only requires that a
contiguous_iterator
be returned, which does not necessarily have to be a raw pointer.Example:
Clang-Tidy output:
Godbolt demo: https://godbolt.org/z/Taraa7zxK