The slice and gslice Classes : valarray slice « valarray « C++ Tutorial






#include <iostream>
#include <valarray>
using namespace std;
   
int main()
{
  valarray<int> v(10), result;
  unsigned int i;
   
  for(i=0; i<10; i++) v[i] = i;
   
  cout << "Contents of v: ";
  for(i=0; i<10; i++)
    cout << v[i] << " ";
  cout << endl;
   
  result = v[slice(0,5,2)];
   
  cout << "Contents of result: ";
  for(i=0; i<result.size(); i++)
    cout << result[i] << " ";
   
  return 0;
}








20.6.valarray slice
20.6.1.gslice of valarray
20.6.2.The slice and gslice Classes
20.6.3.valarray slice