#ifndef UTILS__SHOW_H #define UTILS__SHOW_H #ifndef SHOWS #include #define SHOWS std::cerr #endif #define SELF_TYPE_PRINT \ template \ inline friend std::basic_ostream & operator <<(std::basic_ostream &o, self_type const& me) \ { me.print(o);return o; } \ typedef self_type has_print; #define SELF_TYPE_PRINT_ANY_STREAM \ template \ friend inline O & operator <<(O &o, self_type const& me) \ { me.print(o);return o; } \ typedef self_type has_print; #define SELF_TYPE_PRINT_OSTREAM \ friend inline std::ostream & operator <<(std::ostream &o, self_type const& me) \ { me.print(o);return o; } \ typedef self_type has_print; #define PRINT_SELF(self) typedef self self_type; SELF_TYPE_PRINT_OSTREAM #undef SHOWALWAYS #define SHOWALWAYS(x) x /* usage: #if DEBUG # define IFD(x) x #else # define IFD(x) #endif SHOWS(IFD,x) SHOWS(IFD,y) SHOW(IFD,nl_after) will print x=X y=Y nl_after=NL_AFTER\n if DEBUG. SHOW3(IFD,x,y,nl_after) is short for the same SHOWP("a") will just print "a" careful: none of this is wrapped in a block. so you can't use one of these macros as a single-line block. */ #define SHOWP(IF,x) IF(SHOWS<