#include <iostream>
#include <type_traits>
template<typename TF>
void write_debug_output( std::ostream & out, TF const& f ) {
out << f;
}
struct tracer {
std::ostream & out;
tracer( std::ostream & out, char const * file, int line )
: out( out ) {
out << file << ":" << line << ": ";
}
~tracer() {
out << std::endl;
}
template<typename TF, typename ... TR>
void write( TF const& f, TR const& ... rest ) {
write_debug_output( out, f );
out << " ";
write( rest... );
}
template<typename TF>
void write( TF const& f ) {
write_debug_output( out, f );
}
void write() {
//handle the empty params case
}
};
#define TRACE(...) tracer( std::cout, __FILE__, __LINE__ ).write( __VA_ARGS__ )
struct my_object { };
void write_debug_output( std::ostream & out, my_object const & f ) {
out << "**Mine**";
}
int main() {
my_object a;
TRACE( 1, a, "okay" );
TRACE( 5.6, my_object() );
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHlwZV90cmFpdHM+Cgp0ZW1wbGF0ZTx0eXBlbmFtZSBURj4Kdm9pZCB3cml0ZV9kZWJ1Z19vdXRwdXQoIHN0ZDo6b3N0cmVhbSAmIG91dCwgVEYgY29uc3QmIGYgKSB7CglvdXQgPDwgZjsKfQoKc3RydWN0IHRyYWNlciB7CglzdGQ6Om9zdHJlYW0gJiBvdXQ7Cgl0cmFjZXIoIHN0ZDo6b3N0cmVhbSAmIG91dCwgY2hhciBjb25zdCAqIGZpbGUsIGludCBsaW5lICkKCQk6IG91dCggb3V0ICkgewoJCW91dCA8PCBmaWxlIDw8ICI6IiA8PCBsaW5lIDw8ICI6ICI7Cgl9Cgl+dHJhY2VyKCkgewoJCW91dCA8PCBzdGQ6OmVuZGw7Cgl9CgkKCXRlbXBsYXRlPHR5cGVuYW1lIFRGLCB0eXBlbmFtZSAuLi4gVFI+Cgl2b2lkIHdyaXRlKCBURiBjb25zdCYgZiwgVFIgY29uc3QmIC4uLiByZXN0ICkgewoJCXdyaXRlX2RlYnVnX291dHB1dCggb3V0LCBmICk7CgkJb3V0IDw8ICIgIjsKCQl3cml0ZSggcmVzdC4uLiApOwoJf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