CPP/Template Print
From ProgrammingExamples
#include <iostream> #include <string> namespace Print { using std::cout; using std::endl; using std::string; template<typename T> void print(const T& arg){ cout << arg; } void print(){ cout << endl; } template<> void print(const bool& b){ cout << (b ? "TRUE" : "FALSE" ); } template< typename T> void println(const T& arg){ cout << arg << endl; } void println(){ cout << endl; } template<> void println(const bool& b){ cout << (b ? "TRUE" : "FALSE") << endl; } template< typename FrwdItr > void print(FrwdItr begin, FrwdItr end, const string& sep){ while(begin != end){ cout << *begin++ << sep; } } }; int main(){ using namespace Print; println(true); println(false); string A[4] = {"this","is","a","string"}; print(A,A+4," "); print(); return 0; }