std::size_t size() const; |
Returns the number of elements in the valarray.
(none).
Number of elements in the valarray.
#include <iostream> #include <valarray> int main() { std::valarray<double> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; std::cout << "Average: " << a.sum()/a.size() << '\n'; }
Output:
Average: 5.5
changes the size of valarray (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/numeric/valarray/size