I'm trying to teach myself some C++17.
Why is the compiler throwing an error for the below code snippet?
#include <iostream> #include <vector>#include <iterator>int main() { std::vector<int> v = { 3, 1, 4 }; std::cout << std::size(v) << '\n'; int a[] = { -5, 10, 15 }; std::cout << std::size(a) << '\n';}
The compiler throws the following error
manish@Manish-Tummala:~/c_files$ g++ 6.cpp -o - 6.out6.cpp: In function ‘int main()’:6.cpp:8:23: error: ‘size’ is not a member of ‘std’ std::cout << std::size(v) << '\n'; ^~~~6.cpp:8:23: note: suggested alternative: ‘size_t’ std::cout << std::size(v) << '\n'; ^~~~ size_t6.cpp:11:23: error: ‘size’ is not a member of ‘std’ std::cout << std::size(a) << '\n'; ^~~~6.cpp:11:23: note: suggested alternative: ‘size_t’ std::cout << std::size(a) << '\n'; ^~~~ size_t