我在构建项目时收到以下编译器错误:
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;
}
..}
如何解决此错误?
由于 Raghu