// ####################### templates.cpp #include #include #include template < class T > T twice (T a) { return 2 * a; } template < class iter > void view (iter b, iter e) { iter it; for (it = b; it != e; it++) { cout << *it << "\n"; } cout << "\n"; } #define BE(v) v.begin(), v.end() main () { cout << twice (2) << "\n"; double a = 3.0; cout << twice (a) << "\n"; cout << "\n"; set < int >s; s.insert (7); s.insert (6); view (s.begin (), s.end ()); vector < int >v (3, 2); view (BE (v)); }