Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Why std::size() is not a member of std in gcc 8.2.0

$
0
0

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

Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>