Last active
May 31, 2019 09:40
-
-
Save lgarron/456dcd8b92b104a8d7ba to your computer and use it in GitHub Desktop.
Trolling C++ using console.log
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
/* 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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can't log JSON...I mean struct.