Skip to content

Instantly share code, notes, and snippets.

Created August 20, 2013 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dcc493564d5f2170ca92 to your computer and use it in GitHub Desktop.
Save anonymous/dcc493564d5f2170ca92 to your computer and use it in GitHub Desktop.
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