Problems with the alarm clock, version 1.59

The following code is expected to increase 1.57:

#include <iostream> #include <boost/log/trivial.hpp> struct Foo { int d=1; }; std::ostream& operator<<(std::ostream& out, const Foo& foo) { out << "Foo: " << foo.d; return out; } int main() { BOOST_LOG_TRIVIAL(info) << Foo(); return EXIT_SUCCESS; } 

with an increase of 1.59 code failure. First gcc error message:

error: no match for 'operator <<<(operand types' Boost :: log :: v2s_mt_posix :: basic_record_ostream and' Foo)

Neither the documentation nor the release notes document what needs to be changed.

+6
source share
1 answer

Current Version Looks like a problem in the enable_if_formatting_ostream structure. It has been added to this commit . And it looks like

 template< typename StreamT, typename R > struct enable_if_formatting_ostream {}; template< typename CharT, typename TraitsT, typename AllocatorT, typename R > struct enable_if_formatting_ostream< basic_formatting_ostream< CharT, TraitsT, AllocatorT >, R > { typedef R type; }; 

And now operator << is

 template< typename StreamT, typename T > inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type operator<< (StreamT& strm, T const& value) 

Before he was

 template< typename CharT, typename TraitsT, typename AllocatorT, typename T > inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, T const& value) 

and since record_ostream derived from formatting_ostream , the compiler can find the overload, but now no, because SFINAE is used, and the struct will have a type typedef only when formatting_ostream used. And this can be a workaround for this case.

+4
source

All Articles