///////////////////////////////////////////////////////////////////// // selection.cpp - compile-time type selections // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2004 // ///////////////////////////////////////////////////////////////////// #include ///////////////////////////////////////////////////////////////////// // type selection template struct SELECT { typedef T RET; }; template struct SELECT { typedef F RET; }; class TrueType { public: void say() { std::cout << "\n I'm true"; } }; class FalseType { public: void say() { std::cout << "\n I'm false"; } }; ///////////////////////////////////////////////////////////////////// // Demonstrations void main() { std::cout << "\n Demonstrating TMP Selections"; std::cout << "\n ==============================\n\n"; SELECT::RET first; // declared type first.say(); SELECT::RET second; // declared type second.say(); std::cout << "\n\n"; }