Open
Description
Need a check that will find cases where std::vector
is used redundantly for fixed-size, statically initialized data. The check will suggest a replacement with std::array
for better performance and clarity.
BEFORE:
bool foo(int val) {
std::vector<int> v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}
AFTER:
bool foo(int val) {
std::array<int, 5> v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}
In C++17 mode the check will produce replacement with CTAD usage:
bool foo(int val) {
std::array v = { 1,2, 5, 10, 33 };
return std::range::find(v, val) != v.end();
}