/////////////////////////////////////////////////////////////////// // types.cpp - demonstrate use of value_type from STL container // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2001 // /////////////////////////////////////////////////////////////////// #pragma warning(disable : 4786) #include #include #include #include #include #include using namespace std; template struct Int2Type { enum { value = v }; }; //template //void display(container &c) { // // display(container &c, Int2Type); //} template void displayStrElem(T &t) { cout << "\"" << t.c_str() << "\""; } template void displayElem(T &t) { cout << t; } template void display(container &c, Int2Type()) { container::const_iterator it; for(it=c.begin(); it!=c.end(); it++) if(holdsString) displayStrElem(*it); else displayElem(*it); } void main() { string strArray[] = { "one", "two", "three" }; list listStr(&strArray[0],&strArray[3]); display,true>(listStr,Int2Type()); }