Last active
November 15, 2017 19:36
-
-
Save metaflow/87d7df206e1e0a9fa9eb8a5dc4ac6bea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#if defined(LOCAL) | |
#include "logging.h" | |
#define L(x...) (debug(x, #x)) | |
#else | |
#define L(x, ...) (x) | |
#endif | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
int a, b; | |
cin >> a >> b; | |
if (L(a + b, a, b) == 42) { | |
cout << "well done!" << endl; | |
} | |
} |
This file contains hidden or 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
#ifndef H_LOGGING | |
#define H_LOGGING | |
// https://louisdx.github.io/cxx-prettyprint/ | |
#include "prettyprint.hpp" | |
template<typename T> | |
void _out_to_stream(std::ostream& ss, T&& arg) { | |
ss << std::forward<T>(arg); | |
} | |
template<typename T, typename... O> | |
void _out_to_stream(std::ostream& ss, T&& arg, O&&... args) { | |
ss << std::forward<T>(arg) << ' '; | |
_out_to_stream(ss, std::forward<O>(args)...); | |
} | |
template<typename T, typename... O> | |
decltype(auto) debug(T&& arg, O&&... args) { | |
std::stringstream ss; | |
_out_to_stream(ss, std::forward<T>(arg), std::forward<O>(args)...); | |
std::cerr << ss.str() << std::endl; | |
return std::forward<T>(arg); | |
} | |
#endif // H_LOGGING |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment