-
-
Save anonymous/dcc493564d5f2170ca92 to your computer and use it in GitHub Desktop.
How many people know that the comma operator is overloadable?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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