Skip to content

Instantly share code, notes, and snippets.

/gist:dcc493564d5f2170ca92 Secret

Created Aug 20, 2013
Embed
What would you like to do?
How many people know that the comma operator is overloadable?
#include <iostream>
template<typename T>
std::ostream& operator,(std::ostream& s, const T& x)
{
return s << ", " << x;
}
int main(int argc, char* argv[])
{
std::cout << "A", "bunch", "of", "comma-separated", "strings";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment