std::valarray<T>::size (3) - Linux Man Pages

std::valarray<T>::size: std::valarray<T>::size

NAME

std::valarray<T>::size - std::valarray<T>::size

Synopsis


std::size_t size() const;


Returns the number of elements in the valarray.

Parameters


(none)

Return value


Number of elements in the valarray.

Example


// Run this code


  #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

See also


       changes the size of valarray
resize (public member function)