#define __MINMAX_DEFINED // use STL's generic min and max templates #include "vector.h" // include STL vector implementation #include "algo.h" // include STL algorithm implementations #include <iostream.h> template <class value_type> class gen { public: gen() : start(0), step(1) {} gen (value_type sta, value_type ste) : start(sta), step(ste) {} value_type operator() (void) { value_type tmp = start; start += step; return tmp; } private: value_type start, step; }; void main (void) { vector<int> v(10); generate (v.begin(), v.end(), gen<vector<int>::value_type> (1, 2) ); copy (v.begin(), v.end(), ostream_iterator<int> (cout, " ") ); }
Johannes Weidl (J.Weidl@infosys.tuwien.ac.at) - Apr 16, 1996