#ifndef WRAPPERH #define WRAPPERH #include #include using namespace std; template class wrapper { //primary template const T t; public: wrapper(const T& initial_t): t(initial_t) {} void print() const; }; template inline void wrapper::print() const {cout << t;} template class wrapper { //partial specialization const T *const p; public: wrapper(const T *initial_p): p(initial_p) {} void print() const; }; template void wrapper::print() const { cout << p; if (p != 0) { cout << " -> "; wrapper(*p).print(); } } template <> class wrapper { //explicit specialization const char *const p; public: wrapper(const char *initial_p): p(initial_p) {} void print() const; }; //template <> //No preamble. inline void wrapper::print() const {cout << "\"" << p << "\"";} template class wrapper > { //another partial specialization const vector v; public: wrapper(const vector& initial_v): v(initial_v) {} void print() const; }; template void wrapper >::print() const { cout << "("; for (typename vector::const_iterator it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) { cout << ", "; } wrapper(*it).print(); } cout << ")"; } #endif