Opened 7 years ago
Closed 7 years ago
#11549 closed Bugs (fixed)
ostream& operator<< overload no longer picked up by boost log
Reported by: | Owned by: | Andrey Semashev | |
---|---|---|---|
Milestone: | To Be Determined | Component: | log |
Version: | Boost 1.59.0 | Severity: | Regression |
Keywords: | Cc: | kingsbfs@… |
Description
Boost log does no longer seem to reliably pick up custom stream operators in boost 1.59.0 (tested with vc14 and vc12). In the example given below the custom operator works fine for cout but isn't found when trying to use it normally for logging. The operator is however found if something else is piped in first. Compiling the same example with 1.58.0 (only tested with vc12) works as expected.
#include <iostream> #include <ostream> #include <boost/log/trivial.hpp> struct Mine {}; std::ostream& operator << (std::ostream& t, const Mine& m) { t << "Works"; return t; }; int main() { Mine m; std::cout << m << std::endl; // Works BOOST_LOG_TRIVIAL(warning) << m; // error C2678: binary '<<': no operator found which takes a left-hand operand of type 'boost::log::v2s_mt_nt5::basic_record_ostream<char>' (or there is no acceptable conversion) BOOST_LOG_TRIVIAL(warning) << "" << m; // Works return 0; };
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Cc: | added |
---|
comment:3 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in https://github.com/boostorg/log/commit/7da193fde1a9c1bc925ee980339f4df2e1a66fa7. Thanks for the report.
Note:
See TracTickets
for help on using tickets.
This also breaks all logging whenever boost::format is used for record formatting. On MVC12 compiler I get the following error:
as a temporary solution I redefined my log macro to add an extra empty string: