Question

I get a ICL compiler warning when inheriting from std::streambuf saying that the destructor is not compatible, any ideas what I'm doing wrong here? Making it a virtual destructor does not work either.

warning #809: exception specification for virtual function "CAbcBuffer::~CAbcBuffer" is incompatible with that of overridden function "std::basic_streambuf<_Elem, _Traits>::~basic_streambuf [with _Elem=char, _Traits=std::char_traits]"

class CAbcBuffer : public std::streambuf
{
    protected:
        /** Work buffer */
        char *buffer;
    public:
        explicit CAbcBuffer()
        {
            /*
            Stores the beginning pointer, the next pointer, and the end pointer for the 
            input buffer
            */
            buffer = new char[100];
            std::streambuf::setg(buffer, buffer, buffer);
        }

        ~CAbcBuffer() {
            delete [] buffer;
        }
}
Was it helpful?

Solution

You are missing the throw() declaration for your destructor. This will fix the problem:

~CAbcBuffer() throw() {
    delete [] buffer;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top