I took the example from http://www.boost.org/doc/libs/1_61_0/libs/log/example/doc/tutorial_trivial_flt.cpp and added a bitfield print:
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
namespace logging = boost::log;
//[ example_tutorial_trivial_with_filtering
void init()
{
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
}
struct BF {
unsigned int b : 8;
BF() : b(0) {}
};
int main(int, char*[])
{
init();
BF bf;
BOOST_LOG_TRIVIAL(info) << "An informational severity message " << bf.b;
return 0;
}
//]
With boost 1.61 I got a compilation error:
cannot bind bitfield 'bf.BF::b' to 'unsigned int&'
With boost 1.57 the code is compiled and run (prints: [2016-09-19 20:21:33.018112] [0x000007fd1d5be672] [info] An informational severity message 0)
notice that:
- cout of-course can handle this (so I think it is not just a backward compatibility issue, but a bug)
- boost 1.61 can handle const bitfield, e.g
BOOST_LOG_TRIVIAL(info) << "An informational severity message " << BF().b;
I'm searching for workaround. Suggestions?