Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ---------------------------------------------------------------------------
- * ** This software is in the public domain, furnished "as is", without technical
- * ** support, and with no warranty, express or implied, as to its usefulness for
- * ** any purpose.
- * **
- * ** The file provide a way to avoid printing interleaved words in a multithreaded
- * ** environment. It works like qDebug() for the Qt framework
- * **
- * ** Usage :
- * ** Print() << " The debug value = " << 42;
- * ** Print() << " The debug value = " << 56;
- * **
- * ** Author: Arthur Sonzogni
- * ** -------------------------------------------------------------------------*/
- #ifndef PRINT_HEADER_GUARD_823
- #define PRINT_HEADER_GUARD_823
- #include <iostream>
- #include <sstream>
- class Print
- {
- public:
- template<typename T> Print& operator<<(const T& x)
- {
- ss << x;
- return *this;
- }
- ~Print()
- {
- std::cerr << ss.rdbuf() << std::endl;
- }
- private:
- std::stringstream ss;
- };
- #endif /* end of include guard: PRINT_HEADER_GUARD_823 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement