printf - Make fprintf to write to std::stringstream -
function fprintf
writes file*
. have debugprint function writes stringstream. don't want change function used @ many places , break code.
how can pass stringstream fprintf?
update : can wrap stringstream
file
, unwrap back?
you can't "pass" ostream fprintf. file
structure platform dependent.
this not best way, can create evil macro:
#undef fprintf #define fprintf my_fprintf
and can create 2 my_fprintfs, 1 takes file*
, , takes std::stringstream&
argument.
you can avoid macro calling my_fprintf directly, have modify call site.
you can't "wrap stringstream in file*" portably, there system specific ways. if that's after, linux example has fopencookie() take function pointers read/write functions. create functions wrap std::stringstream.
Comments
Post a Comment