Skip to content

Instantly share code, notes, and snippets.

@lgarron
Last active May 31, 2019 09:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgarron/456dcd8b92b104a8d7ba to your computer and use it in GitHub Desktop.
Save lgarron/456dcd8b92b104a8d7ba to your computer and use it in GitHub Desktop.
Trolling C++ using console.log
/* Vararg code by Daniel Cheng (@zetafunction) */
#include <iostream>
#include <utility>
struct {
template<typename T>
static void log(T&& t) {
std::cout << t << "\n";
}
template<typename T, typename...Args>
static void log(T&& t, Args&&... args) {
std::cout << t << " ";
log(std::forward<Args>(args)...);
}
} console;
int main() {
console.log("1", 2, "3");
}
@linonetwo
Copy link

This can't log JSON...I mean struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment