00001 #ifndef NMWR_GB_PRINT_RANGE_H
00002 #define NMWR_GB_PRINT_RANGE_H
00003
00004
00005
00006
00007 #include <iostream.h>
00008
00023 template<class It>
00024 struct iter_range {
00025 It b;
00026 It e;
00027 iter_range(It bb, It ee) : b(bb), e(ee) {}
00028 };
00029
00033 template<class It>
00034 inline
00035 iter_range<It> range(It bb, It ee)
00036 { return iter_range<It>(bb,ee); }
00037
00038
00042 template<class It>
00043 inline
00044 ostream& operator<<(ostream& out, iter_range<It> r)
00045 {
00046 while(r.b != r.e) {
00047 out << *(r.b) << ' ';
00048 ++r.b;
00049 }
00050 return out;
00051 }
00052
00056 template<class It>
00057 inline
00058 istream& operator>>(istream& in, iter_range<It> r)
00059 {
00060 while(r.b != r.e) {
00061 in >> *(r.b);
00062 ++r.b;
00063 }
00064 return in;
00065 }
00066
00067 #endif
00068