c++ - How to make use of existing operator<< overloads when logging with Pantheios? -


if have ton of user defined types implement operator<< write std::ostream. how can uses these when logging types pantheios?

well there way can reuse operator<< ain't pretty. use boost::lexical_cast library convert data-type std::string data type, pantheios supports natively. if have operator<< defined point class type:

pantheios::log_error("point: ", boost::lexical_cast<string>(point_object))

there caveats of course. many people complain boost::lexical_cast slow. can google , find articles speak of same (http://stackoverflow.com/questions/1250795/very-poor-boostlexical-cast-performance, http://accu.org/index.php/journals/1375). considering pantheios boasts superior performance, may lose of advantage. , obvious, add few hundred header files project when add boost::lexical_cast. have type in more letters (e.g. boost::lexical_cast) each conversion (you minimize macro - #define blcs boost::lexical_cast<string> - thats more indirection people may comfortable with).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -