Modify

Opened 3 years ago

Closed 3 years ago

#11549 closed Bugs (fixed)

ostream& operator<< overload no longer picked up by boost log

Reported by: dd0t@… 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;
};

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by Alexander Filonov <kingsbfs@…>

This also breaks all logging whenever boost::format is used for record formatting. On MVC12 compiler I get the following error:

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'boost::basic_format<char,std::char_traits<char>,std::allocator<char>>' (or there is no acceptable conversion)

as a temporary solution I redefined my log macro to add an extra empty string:

#define LOG(lg,sev) BOOST_LOG_SEV(lg, sev) << ""

comment:2 Changed 3 years ago by Alexander Filonov <kingsbfs@…>

Cc: kingsbfs@… added

comment:3 Changed 3 years ago by Andrey Semashev

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Andrey Semashev.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.