Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef LOG_H
- #define LOG_H
- #include <iostream>
- #ifdef DEBUG
- class VariadicLog
- {
- public:
- template<typename T> VariadicLog& operator , (const T& value)
- {
- std::cout<<value;
- return *this;
- }
- ~VariadicLog()
- {
- std::cout<<std::endl;
- }
- };
- #define log(...) VariadicLog(),__VA_ARGS__
- #else
- #define log(...)
- #endif
- #ifdef VERBOSE
- #define verbose_log(...) VariadicLog(),__VA_ARGS__
- #else
- #define verbose_log(...)
- #endif
- #endif
- // example use: log("Entering method xxx with x: ", x, ", y: ", y);
- // (evaluates to nothing when DEBUG is not defined)
Advertisement
Add Comment
Please, Sign In to add comment