I have found that many still have issue using std::size()
general template function.
As mentioned on C++ reference, std::size was implemented in C++17.
Now, the difference comes with the compiler used when using the said implementation.
Assume following example.
#include <iostream>
int main()
{
int numbers[] = {10, 20, 30, 40, 50};
std::cout << std::size(numbers);
return 0;
}
The example works on C++17 (GCC) and newer versions (C++20)).
But it does not work on C++17 (Clang) or older versions of GCC (C++14).
So know the compiler that you are using.
Change compiler in Visual Studio
Change compiler in CLion
Change compiler in Code::Blocks
Change compiler in Visual Studio Code