2015-08-24 7 views
6

Der folgende Code als mit Boost 1,57 erwartet funktioniert:Probleme mit Boost-Protokoll, Version 1.59

#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; 
} 

mit Boost 1,59 der gleichen Code fehlschlägt. Die erste gcc-Fehlermeldung lautet:

Weder die Dokumentation noch die Versionshinweise dokumentieren, was geändert werden muss.

+0

Live-Version: http://melpon.org/wandbox/permlink/Xn1hDoe7Zg7cynRX Sieht aus wie 'enable_if_formatting_ostream' ist defekt. – ForEveR

Antwort

4

Live version Sieht aus wie Problem ist in enable_if_formatting_ostream struct. Es wurde in this commit hinzugefügt. Und sieht aus wie

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; }; 

Und jetzt operator << ist

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

Vorher war es

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) 

und seit record_ostream von formatting_ostream Compiler abgeleitet wird, kann Überlastung finden, aber jetzt nicht, da SFINAE ist used und struct haben type typedef nur wenn formatting_ostream verwendet wird. Und this kann Abhilfe für diesen Fall sein.

+3

Nach einem Blick auf den Boost-Trac, wurde dieser Bug aufgezeichnet und behoben: https://svn.boost.org/trac/boost/ticket/11549 –

+1

Wie auf der Erde hat dies durch Regressionstests bekommen? –