c++ - 在 VS 2005 中获取编译器错误'二进制'<<':找不到运算符'
问题描述
构建项目时出现以下编译器错误:
XMLHelper.h(22) : 错误 C2678: 二进制 '<<' : 未找到采用 'COSB::AnyException' 类型的左侧操作数的运算符(或没有可接受的转换)
XMLHelper.h 的代码:
class XMLException : public COSB::Exception
{
public:
XMLException(const MSXML2::IXMLDOMParseErrorPtr &verr, const char *prefix_description="XML error")
: Exception(verr->errorCode)
{
/*line 22 error line */
*this << prefix_description << " " << std::hex << long(verr->errorCode) << std::dec;
...}
XMLHelper.h 不直接属于我的项目。我检查了具有以下函数定义的 exception.h:
class ExceptionBase : public std::exception
{ ...}
// Any exception including Win32 structured exceptions and COSB::Exception.
class AnyException: public ExceptionBase
{
public:
// This insertion operator needed to be declared as a member function or the
//compiler gets confused as to which template function to apply.
// Notice that stateful stream manipulators like width will probably not
//work
AnyException &operator<<( std::ostream& (_cdecl *f)(std::ostream&) )
{
ExceptionBufferStream buf(FormatHolder());
(*f)(buf);
AppendToDescription(buf.c_str(),buf.LineSize());
return *this;
}
..}
如何解决此错误?
谢谢拉古
解决方案
推荐阅读
- javascript - 如何使用 Node-JS 在浏览器的客户端执行 javascript 函数?
- java - 如何在 IntelliJ 插件中添加事件侦听器?
- r - 填充参数使 geom_label() 中的位置参数无效
- windows - 在 Windows 10 设备驱动程序中使用互斥锁导致代码 39
- angular - 使用公共模块文件夹的多个 Angular 应用程序
- powerbi - 如何在 Power BI 中合并多个表,同时附加一个包含表名称的新列?
- java - 当lib类获取键值时,如何修改属性文件中的值?
- javascript - 纹理是将音频数据传输到 GLSL 的唯一方法吗?
- erlang - 为什么我在运行 eunit 测试时会出错?
- ruby-on-rails - Rails 4:删除目录后如何重新创建 Postgres 数据库