助推日志的问题,版本1.59
Problems with boost log, version 1.59
下面的代码在boost 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;
}
与boost 1.59相同的代码失败。第一个gcc错误信息是:
error: no match for ' operator<<'(操作数类型为' boost::log::v2s_mt_posix::basic_record_ostream ' and ' Foo ')
文档和发行说明都没有说明需要更改的内容。
现场版看起来问题是在enable_if_formatting_ostream
结构。它是在这次提交中添加的。看起来像
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; };
现在operator <<
是
template< typename StreamT, typename T >
inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type
operator<< (StreamT& strm, T const& value)
以前是
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)
并且由于record_ostream
派生自formatting_ostream
编译器可以找到过载,但现在没有,因为使用了SFINAE,并且只有在使用formatting_ostream
时结构才会具有type
类型定义。这是一种变通方法
相关文章:
- python 和 swig 版本兼容性问题
- 使用不同版本的 gcc 和 g++ 进行编译时出现问题
- Xcode(版本9.2(9C40B)):试图包括Boost时C 语义和链接器问题
- 将词法分析器字符串累加器移植到新版本的 Quex 时出现问题
- 将GCC版本升级到发行版附带的版本以外的版本是否有任何问题
- 在发布版本中删除类指针会导致内存问题
- Linux 中 gcc 4.3 版本的编译问题
- 具有状态的Microsoft编译器版本19.16.27024.1的问题
- 外部库Boost版本问题
- 将早期 MSVC 版本生成的代码重新生成为较新版本时可能遇到的问题
- gcc 4.8或更早版本对正则表达式有问题吗
- 提升链接问题 - 多个版本
- OpenGL 版本问题
- 如何在编译C++代码时解决一些版本控制问题
- C++STL版本控制问题+Boost
- 避免DLL版本控制问题
- Windows 10 home的c++ Windows版本问题
- 为什么我有一个兼容版本问题使用libpng与Xcode
- XP内嵌CRT版本问题.LoadLibraryEx失败
- 提升文件系统版本 3 问题