I have a virtual method type int_type
in code being adapted from here that is the only case where the code gives the compile error:
‘int_type’ does not name a type
int_type ThreadLogStream::overflow(int_type v)
^.
Debugging steps so far
If I hover over any other instance of
int_type
in the Qt Creator IDE, it showstraits_type::int_type std::basic_streambuf::int_type
, implying every other instance ofint_type
should not be causing problems.According to this reference, the int_type does indeed belong to
basic_streambuf
, but calling itTraits::int_type
did not work.I attempted to typedef the problem variable, as demonstrated in the typedefs below, but
char_type
andtraits_type
were not recognized.
threadlogstream.cpp
...
int_type ThreadLogStream::overflow(int_type a)
{
int_type b = a; //This gives no errors
return b;
}
...
threadlogstream.hpp
#include <iostream>
#include <streambuf>
#include <string>
//typedef std::basic_streambuf< char_type, traits_type> base_class;
//typedef typename base_class::int_type int_type;
class ThreadLogStream : public QObject, std::basic_streambuf<char> {
Q_OBJECT
public:
ThreadLogStream(std::ostream &stream);
~ThreadLogStream();
protected:
virtual int_type overflow(int_type v); // This gives no errors
virtual std::streamsize xsputn(const char *p, std::streamsize n);
}
Please help - I am losing hair over this.